6 - 11 6 - 11
MELSEC-Q
6 I/O Processing of Data Files
Example
1 ' Register data in a random file
2 '
10 OPEN "R-TEST.DAT" AS #1
:
'Generates R-TEST.DAT file and names it as
file number 1
20 FIELD #1,8 AS D$,30 AS H$,2 AS K$,4 AS W$
:
'Assigns the file buffer
30 R = 0
40 R = R+1
:
'Specifies the record number
50 INPUT "Date:";D1$
60 LINE INPUT "Item Name:";H1$
70 INPUT "Quantity:";K1
80 INPUT "Rate(%):";W1
90 LSET D$=D1$
:
'Writes data entered in line 50 into file buffer
100 LSET H$=H1$
:
'Writes data entered in line 60 into file buffer
110 LSET K$=MKI$(K1)
:
'Writes data entered in line 70 into file buffer
120 LSET W$=MKS$(W1)
:
'Writes data entered in line 80 into file buffer
130 PUT #1,R
140 INPUT "Continue? (Y/N)";Y$
150 IF Y$="Y" OR Y$="y" GOTO 40
:
'Repeats data input
160 CLOSE #1
:
'Closes the file
170 END
1 ' Read data from the random file written above
2 '
10 OPEN "R-TEST.DAT" AS #1
:
'Opens R-TEST.DAT file and names it as file
number 1
20 FIELD #1,8 AS D$, 30 AS H$, 2 AS K$, 4 AS W$
:
'Assigns the file buffer
30 FOR R=1 TO LOF(1)
:
'Repeats at the last of random file (value
shown by the LOF function)
40 GET #1,R
:
'Reads data from the random file
50 D1$=D$:H1$=H$
:
'Reads data from the file buffer
60 K=CVI(K$)
70 W=CVS(W$)
80 PRINT D$,H$;K;"quantity",W;"%"
:
'Displays the read data
90 PRINT
100 NEXT R
110 CLOSE #1
:
'Closes file
120 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...