6 - 6 6 - 6
MELSEC-Q
6 I/O Processing of Data Files
Example
1 ' Register data to a sequential file
2 '
10 OPEN "0:TEST.DAT" FOR OUTPUT AS #1
: 'Generates TEST.DAT file and names it as file
number 1
20 INPUT "Date:";D$
30 LINE INPUT "Item Name:";H$
40 INPUT "Quantity:";K
50 INPUT "Rate (%):";W
60 PRINT #1,D$;",";
:
'Data entered in line 20 is written into the file
70 PRINT #1,CHR$(&H22);H$;CHR$(&H22);",";
:
'Data entered in line 30 is written into the file
80 PRINT #1,K;",";
:
'Data entered in line 40 is written into the file
90 PRINT #1 USING "###.#";W
:
'Data entered in line 50 is written into the file
100 INPUT "Continue? (Y/N)";Y$
110 IF Y$="Y" OR Y$="y" GOTO 20
:
'Repeats data input
120 CLOSE #1
:
'Closes the file
130 END
1 ' Read data from the sequential file written above
2 '
10 OPEN "0:TEST.DAT" FOR INPUT AS #1
:
'Opens the TEST.DAT file using input mode
and names it as file number 1
20 IF EOF(1) GOTO 100
:
'Ends program when the end of file is
detected
30 INPUT #1, D$
:
'Reads date written in the file
40 INPUT #1, H$
:
'Reads item name written in the file
50 INPUT #1, K
:
'Reads quantity written in the file
60 INPUT #1, W
:
'Reads rate written in the file
70 PRINT D$,H$,K:"quantity",W:"%"
:
'Displays data that has been read
80 PRINT
90 GOTO 20
100 CLOSE #1
:
'Closes the file
110 END
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...