Mitsubishi QD51 Programming Manual page 129

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

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

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents