Tải bản đầy đủ
APPENDIX A.26: DISC DATA RECALL COMPUTER PROGRAM “DISCDATA”

APPENDIX A.26: DISC DATA RECALL COMPUTER PROGRAM “DISCDATA”

Tải bản đầy đủ

86

APPENDICES

cannot be found, an error trap in Line 10010 resumes the program at Line 900 to allow the user to correct the file name
or return to the initial menu.
If the file has been opened successfully, the extension is then checked, and if it is a contour ‘.CON’ or surface ‘.EQD’
data file it will already be in the correct format, etc., so the program returns to Line 400. If the file has a ‘.DAT’ or
other extension, it is then opened and the data read, with an opportunity to view the data on screen before saving to
disc with a ‘.DAT’ extension. After saving the data file, the routine at Line 400 then opens an identity file
‘IDFILE.PGD’ for future reference. The GOSUB 8500 routine at Line 550 then checks to see if a ‘.TXT’ file exists
with a graph title and axes labels. If there is no such file, an error trap at Line 10020 then resumes the program at Line
1000 to enter the data accordingly. If a ‘.TXT’ file already exists, the program continues at Line 1100.
(c) Text file entry

Line numbers 1000–1090

This segment of code is identical to section (c) of Appendix A.25 and can be reused.
(d) Data file printout

Line numbers 1100–1150

This segment of code is similar to section (d) of Appendix A.25, the only difference being the ‘.DAT’ extension check
in Line 1100. Printouts can only be obtained for files with a ‘.DAT’ extension, since contour and surface model files
have too many rows and columns for efficient display. If the user wishes to view the contents of a ‘.CON’ or ‘.EQD’
file, the TYPE command should be used from MS-DOS, e.g. TYPE DFILEN$.EXT$. A printout can also be obtained
by adding>PRN to the above TYPE statement.
This program also requires the following routines.
(e) Appendix A.6
(f) Appendix A.2
(g) Appendix A.4
(h) Appendix A.5
(i) Appendix A.15
(j) Appendix A.16
(k) Appendix A.17

Line numbers 6000–6320
Line numbers 8000–8180
Line numbers 8400–8490
Line numbers 8500–8590
Line numbers 9000–9190
Line numbers 9600 only
Line numbers 10000–10240

Note the addition of two error check Lines 10010 and 10020 as mentioned in section (b) above.
“DISCDATA”—BASIC program

10 REM Presentation Graphics DISC DATA Entry
14 REM (C) Copyright P.H.Milne 1990 : Appendix A.26
16 REM ALL RIGHTS RESERVED
20 REM VERSION PC-1.00, 1990
30 CLEAR : DIM Z(100, 6): GROW = 1: SR% = 2
40 ON ERROR GOTO 10000
50 PCF$ = "PGSCRDSK.PGD"
60 GOSUB 8000: REM Check Screen & Disc
90 WINDOW (0, 0) - (639, 199)
100 CLS : PC$ = "Disc Data Input": GOSUB 9000
110 LOCATE 6, 10: INPUT "Enter DATA File Name - "; DFILEN$

GENERAL ROUTINES AND DATA ENTRY

115
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
500
510
520
530
540
550
560
570
600
601
605
610
620
630
631
635
640
650
660
670

GOTO 600: REM *** Read DATA from DISC ***
LOCATE 7, 10: PRINT "Number of DATA Sets "; NCOL − 1
LOCATE 8, 10: PRINT "Number of DATA Points "; NROW
FOR D = 1 TO NCOL − 1
LOCATE 10, 10: PRINT "X-AXIS"
LOCATE 10, 10 + 10 * D: PRINT "DATA"; D
NEXT D
FOR I = 1 TO NROW
FOR J = 1 TO NCOL
IF I/11 = INT(I/11) AND J = 1 THEN 210 ELSE 250
FOR DELAY = 1 TO 5000: NEXT DELAY
FOR CROW = 1 TO 11
LOCATE 10 + CROW, 10: FOR SP = 1 TO 55: PRINT " "; : NEXT SP
NEXT CROW: GROW = 1
LOCATE 10 + GROW, 10 + (J - 1) * 10: PRINT Z(I, J)
NEXT J: GROW = GROW + 1
NEXT I
LOCATE 22, 10: PRINT "Press C to Continue "; : C$ = INPUT$(1)
IF INSTR("CC", C$) = 0 THEN 280
CLS : GOSUB 9000: EXT$ = ".DAT"
LOCATE 6, 10: PRINT "Please wait ..... saving DATA"
OPEN "O", #1, DDSK$ + DFILEN$ + EXT$
PRINT #1, NROW, NCOL
FOR I = 1 TO NROW
FOR J = 1 TO NCOL − 1
PRINT #1, USING "######.###"; Z(I, J);
NEXT J
PRINT #1, USING "######.###"; Z(I, NCOL)
NEXT I
CLOSE
OPEN "O", #2, DDSK$ + "IDFILE.PGD"
PRINT #2, DFILEN$
PRINT #2, EXT$
CLOSE #2
GOSUB 8500
IF EXT$ <> ".DAT" THEN 9600
GOTO 1100
LOCATE 10, 10:
PRINT "Is DATA stored on Drive "; DDSK$; " (Y/N)";
A$ = INPUT$(1)
IF A$ = "Y" OR A$ = "y" THEN 700
IF A$ = "N" OR A$ = "n" THEN 630 ELSE 600
LOCATE 10, 12:
PRINT "Enter New Logged DATA Drive (e.g. C:\PGDATA\)";
INPUT DDSK$
OPEN "O", #3, MDSK$ + PCF$
PRINT #3, SCR%
PRINT #3, SCD%
PRINT #3, MDSK$

87

88

APPENDICES

680 PRINT #3, DDSK$
690 CLOSE #3
700 LOCATE 16, 10:
701 INPUT "Enter DATA File Extension (e.g. '.PRN')"; EXT$
710 LOCATE 18, 10:
711 PRINT "Please wait ..... reading DATA File "; DFILEN$
720 OPEN "I", #1, DDSK$ + DFILEN$ + EXT$
730 IF EXT$ = ".CON" THEN CLOSE : GOTO 500
740 IF EXT$ = ".EQD" THEN CLOSE : GOTO 500
750 INPUT #1, NROW, NCOL
760 ND = NCOL − 1
770 FOR I = 1 TO NROW
780 FOR J = 1 TO NCOL
790 INPUT #1, Z(I, J)
800 NEXT J
810 NEXT I
820 CLOSE #1
830 LOCATE 20, 10: PRINT "Do you wish to view DATA (Y/N) ";
840 A$ = INPUT$(1)
850 IF INSTR("YNyn", A$) = 0 THEN 830
860 IF A$ = "N" OR A$ = "n" THEN 300
870 CLS : GOSUB 9000
880 LOCATE 6, 10: PRINT "DATA File Name - "; DFILEN$
890 GOTO 120
899 REM *** JUMPS HERE IF DATA FILE NOT FOUND ***
900 CLS : GOSUB 9000
910 PRINT : FILES DDSK$ + "*" + EXT$
920 LOCATE 14, 5: PRINT "Please Type Correct DATA File Name"
930 LOCATE 16, 5:
931 INPUT "(Type 'QUIT' to Return to MENU) "; CNAME$
940 IF CNAME$ = "QUIT" OR CNAME$ = "quit" THEN 9600
950 GOTO 730
1000 CLS : GOSUB 9000: REM *** JUMPS HERE FROM ERROR IN 8500 ***
1010 LOCATE 6, 10: INPUT "Enter Graph Title (Max 40) "; TITLE$
1020 LOCATE 8, 10: INPUT "Enter X-AXIS Title (Max 30) "; LXAXI$
1030 LOCATE 10, 10: INPUT "Enter Y-AXIS Title (Max 11) "; LYAXI$
1040 LOCATE 12, 10:
1041 INPUT "Y-AXIS Title (H)oriz. or (V)ert. "; YLAB$
1042 IF INSTR("HVhv", YLAB$) = 0 THEN 1040
1043 IF YLAB$ = "h" THEN YLAB$ = "H"
1044 IF YLAB$ = "v" THEN YLAB$ = "V"
1050 FOR I = 1 TO NCOL − 1
1060 LOCATE 12 + I, 10:
1061 PRINT "Enter Legend DATA "; I; " (Max 9) ";
1070 INPUT DAT$(I)
1080 NEXT I
1090 GOSUB 8400: REM Store Titles on Disc
1100 IF EXT$ <> ".DAT" THEN 9600
1110 CLS : GOSUB 9000

GENERAL ROUTINES AND DATA ENTRY

1120
1130
1140
1150

89

LOCATE 6, 10: PRINT "Do you wish to print DATA (Y/N) ";
A$ = INPUT$(1)
IF INSTR("YNyn", A$) = 0 THEN 1130
IF A$ = "N" OR A$ = "n" THEN 9600

“DISCDATA”—computer printout for data file ‘PIDEFECT’
Presentation Graphics
Disc Data Input
DATA File - PIDEFECT
**********************
X-AXIS
1.000
2.000
3.000
4.000

DATA 1
37.000
36.000
18.000
9.000

DATA 2
67.000
3.000
17.000
13.000

Graph Title - Defects by construction activity
X-AXIS Title Y-AXIS Title DATA
1
2
3
4

Legend
Design
Specificatn
Workmanship
Supervision

APPENDIX A.27:
DATA GENERATION COMPUTER PROGRAM “KEYBEQUD”
This program was described in Section 1.10.3 and is used to generate a 3-D mathematical surface from a function Z in
terms of X and Y.
Data generation
(a) Initialization and control

Line numbers 10–90

This segment of code is similar to section (a) of Appendix A.25, the only exception being the size of the Z array which
is changed to Z(40,40).
(b) Data file generation

Line numbers 100–540

90

APPENDICES

Before running this program, either from GW-BASIC or QuickBASIC, the user must enter at Line 250 the function that
is to be generated. For example, Eqt 1.1 from Section 1.10.3 would be entered as
The user is asked to enter from the keyboard the data file name and the limits of the surface plot (XMIN, XMAX,
YMIN and YMAX). The X-dimension (XD) and Y-dimension (YD) of the plot is then split into 40 segments in each
direction XTC and YTC to give the grid size. Once data generation is complete, the data is saved in a data file with a
‘.EQD’ extension and as with the other two data entry programs, an ‘IDFILE.PGD’ is saved for identification
purposes.
(c) Text file entry

Line numbers 1000–1100

This segment of code is similar to section (c) of Appendix A.25, but without Lines 1050–1080 as data series labels are
not required. Note, only a vertical Y-axis label is possible at the side of the screen.
This program also requires the following routines.
(d) Appendix A.8
(e) Appendix A.2
(f) Appendix A.4
(g) Appendix A.15
(h) Appendix A.16
(i) Appendix A.17

Line numbers 7000–7090
Line numbers 8000–8180
Line numbers 8400–8490
Line numbers 9000–9190
Line number 9600 only
Line numbers 10000–10240

“KEYBEQUD”—BASIC program
10 REM Presentation Graphics DATA Generation Program
14 REM (C) Copyright P.H.Milne 1990 : Appendix A.27
16 REM ALL RIGHTS RESERVED
20 REM VERSION PC-1.00, 1990
30 CLEAR : DROW = 40: DCOL = 40: DIM Z(DROW, DCOL): SR% = 2
40 ON ERROR GOTO 10000
50 PCF$ = "PGSCRDSK.PGD"
80 GOSUB 8000: REM Check Screen & Disc
90 WINDOW (0, 0) - (639, 199)
100 CLS : PC$ = "Data File Generation": GOSUB 9000
110 LOCATE 6, 10:
111 INPUT "Enter DATA File Name - "; DFILEN$
120 LOCATE 8, 10:
121 INPUT "Enter X-Axis Limits (e.g. −2,2)" ; XMIN, XMAX
130 IF XMIN >= XMAX THEN 120
140 LOCATE 10, 10:
141 INPUT "Enter Y-Axis Limits (e.g. −2,2)" ; YMIN, YMAX
150 IF YMIN >= YMAX THEN 140
160 DX = (XMAX − XMIN): XTC = DX / DCOL
170 NCOL = (XMAX − XMIN) / XTC + 1
180 DY = (YMAX − YMIN): YTC = DY / DROW
190 NROW = (YMAX − YMIN) / YTC + 1
200 LOCATE 20, 10:
201 PRINT "Please Wait ..... Generating Data File"