Tải bản đầy đủ
APPENDIX A.25: KEYBOARD DATA ENTRY COMPUTER PROGRAM “KEYBDATA”

APPENDIX A.25: KEYBOARD DATA ENTRY COMPUTER PROGRAM “KEYBDATA”

Tải bản đầy đủ

GENERAL ROUTINES AND DATA ENTRY

83

The user now has an opportunity to enter a graph title TITLE$, axes labels, LXAXI$ and LYAXI$, and legends for
each of the data series DAT$(I). This information is then stored on disc using the GOSUB 8400 routine described in
Appendix A.4.
(d) Data file printout

Line numbers 1100–1150

The user is now given an opportunity to obtain a data and text file printout using the GOTO 6000 routine described in
Appendix A.6.
This program also requires the following routines:
(e) Appendix A.6
(f) Appendix A.2
(g) Appendix A.4
(h) Appendix A.15
(i) Appendix A.16
(j) Appendix A.17

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

KEYBDATA—BASIC program
10 REM Presentation Graphics Keyboard DATA Entry
14 REM (C) Copyright P.H.Milne 1990 : Appendix A.25
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"
80 GOSUB 8000: REM Check Screen & Disc
90 WINDOW (0, 0) - (639, 199)
100 CLS : PC$ = "Keyboard Input": GOSUB 9000
110 LOCATE 6, 10: INPUT "Enter DATA File Name - "; DFILEN$
120 LOCATE 7, 10: INPUT "Enter Number of DATA Sets "; ND
130 LOCATE 8, 10: INPUT "Enter Number of DATA Points "; NROW
140 NCOL = ND + 1
150 FOR D = 1 TO NCOL - 1
160 LOCATE 10, 10: PRINT "X-AXIS"
165 LOCATE 10, 10 + 10 * D: PRINT "DATA"; D
170 NEXT D
180 FOR I = 1 TO NROW
190 FOR J = 1 TO NCOL
200 LOCATE 23, 10: PRINT "Enter DATA"
210 LOCATE 23, 20: INPUT Z(I, J)
220 LOCATE 10 + GROW, 10 + (J − 1) * 10: PRINT Z(I, J)
230 NEXT J: GROW = GROW + 1
240 IF I/11 = INT(I/11) THEN 250 ELSE 290
250 FOR CROW = 1 TO 11
260 LOCATE 10 + CROW, 10
270 FOR K = 1 TO 70: PRINT " "; : NEXT K

84

APPENDICES

280 NEXT CROW: GROW = 1
290 NEXT I
300 CLS : GOSUB 9000
310 LOCATE 6, 10: PRINT "Please wait ..... saving DATA"
320 OPEN "O", #1, DDSK$ + DFILEN$ + ".DAT"
330 PRINT #1, NROW, NCOL
340 FOR I = 1 TO NROW
350 FOR J = 1 TO NCOL − 1
360 PRINT #1, USING "######.###"; Z(I, J);
370 NEXT J
380 PRINT #1, USING "######.###"; Z(I, NCOL)
390 NEXT I
500 CLOSE
510 OPEN "O", #2, DDSK$ + "IDFILE.PGD"
520 PRINT #2, DFILEN$
530 PRINT #2, ".DAT"
540 CLOSE #2
1000 CLS : GOSUB 9000
1010 LOCATE 6, 10: INPUT "Enter Graph Title (Max 40) "; TITLE$
1020 LOCATE 8, 10: INPUT "Enter X-AXIS Title (Max 40) "; 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 13 + 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 REM *** DATA Printout ***
1110 CLS : GOSUB 9000
1120 LOCATE 6, 10: PRINT "Do you wish to print DATA (Y/N) ";
1130 A$ = INPUT$(1)
1140 IF INSTR("YNyn", A$) = 0 THEN 1130
1150 IF A$ = "N" OR A$ = "n" THEN 9600
“KEYBDATA”—computer printout for data file ‘PHMTEST2’
Presentation Graphics
Disc Data Input
DATA File - PHMTEST2
**********************
X-AXIS
0.000

DATA 1
5.000

DATA 2
10.000

DATA 3
15.000

DATA 4
20.000

DATA 5
25.000

GENERAL ROUTINES AND DATA ENTRY

X-AXIS
10.000

DATA 1
10.000

DATA 2
20.000

20.000
30.000
40.000
50.000
60.000
70.000
80.000
90.000
100.000

13.000
20.000
25.000
20.000
18.000
23.000
28.000
35.000
40.000

25.000
33.000
40.000
35.000
38.000
42.000
50.000
55.000
60.000

DATA 3
30.000

DATA 4
40.000

38.000
42.000
50.000
46.000
41.000
47.000
58.000
65.000
72.000

49.000
58.000
65.000
54.000
50.000
57.000
61.000
72.000
78.000

85

DATA 5
50.000
55.000
65.000
75.000
65.000
60.000
68.000
75.000
85.000
90.000

Graph Title - PC PRESENTATION GRAPHICS
X-AXIS Title - Days from Start of Business
Y-AXIS Title - No of Items
DATA
1
2
3
4
5

Legend
DATA 1
DATA 2
DATA 3
DATA 4
DATA 5
APPENDIX A.26:
DISC DATA RECALL COMPUTER PROGRAM “DISCDATA”

This program is described in Section 1.10.2 and is used either to reload a data file previously saved with a ‘.DAT’
extension as discussed in Appendix A.25, or to load an ASCII data file.
Disc data recall
(a) Initialization and control

Line numbers 10–90

This segment of code is similar to section (a) of Appendix A.25.
(b) Data file recall

Line numbers 100–950

Line numbers 120 to 440 of this routine are identical to that of section (b) of Appendix A.25, and can be reused. This
routine opens at Line 100 with a request for the data filename and then jumps from Line 115 to 600 to recall the
required data file. A check is first made on the disc drive and directory for the location of the data file. The data file
extension is then requested. The program then attempts to open that file in Line 720. If this is unsuccessful and the file

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$