Mitsubishi QD51 Programming Manual page 124

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

Advertisement

6 I/O Processing of Data Files
1 ' Register data to a sequential file
2 '
10 OPEN "0:TEST.DAT" FOR OUTPUT AS #1
20 INPUT "Date:";D$
30 LINE INPUT "Item Name:";H$
40 INPUT "Quantity:";K
50 INPUT "Rate (%):";W
60 PRINT #1,D$;",";
70 PRINT #1,CHR$(&H22);H$;CHR$(&H22);",";
80 PRINT #1,K;",";
90 PRINT #1 USING "###.#";W
100 INPUT "Continue? (Y/N)";Y$
110 IF Y$="Y" OR Y$="y" GOTO 20
120 CLOSE #1
130 END
1 ' Read data from the sequential file written above
2 '
10 OPEN "0:TEST.DAT" FOR INPUT AS #1
20 IF EOF(1) GOTO 100
30 INPUT #1, D$
40 INPUT #1, H$
50 INPUT #1, K
60 INPUT #1, W
70 PRINT D$,H$,K:"quantity",W:"%"
80 PRINT
90 GOTO 20
100 CLOSE #1
110 END
6 - 6
Example
: 'Generates TEST.DAT file and names it as file
number 1
:
'Data entered in line 20 is written into the file
:
'Data entered in line 30 is written into the file
:
'Data entered in line 40 is written into the file
:
'Data entered in line 50 is written into the file
:
'Repeats data input
:
'Closes the file
:
'Opens the TEST.DAT file using input mode
and names it as file number 1
:
'Ends program when the end of file is
detected
:
'Reads date written in the file
:
'Reads item name written in the file
:
'Reads quantity written in the file
:
'Reads rate written in the file
:
'Displays data that has been read
:
'Closes the file
MELSEC-Q
6 - 6

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents