Sequential File I/O Procedures - Mitsubishi QD51 Programming Manual

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

Advertisement

6 I/O Processing of Data Files

6.2 Sequential File I/O Procedures

6 - 3
The following shows an overview of I/O procedures for sequential files.
In sequential files, either read operation or
write operation can be performed per opening
of the file.
(1) Writing data to a file
1) Open a file in output mode.
OPEN "<filename>" FOR OUTPUT AS #n
2) Write the data in the file
PRINT #n, <write data>,
PRINT #n, USING "
3) Close the file
CLOSE #n
When appending (writing) data to a sequential file that already contains data, and if
"OPEN "<filename>" FOR APPEND AS #n" is used to open the file, a new data is
written following the existing data. If "OPEN "<filename>" FOR OUTPUT AS #n" is
used to open the file, all existing data is deleted and the data will be written from the
beginning.
(2) Reading data from a file
1) Open the file in Input mode.
OPEN " <filename> " FOR INPUT AS #n
2) Read the data from the file.
INPUT #n, <variable to store the data read>,
LINE INPUT #n, <variable to store the data read>,
3) Close the file.
CLOSE # n
.........
.........
.........
", <write data>,
Do not forget to use the CLOSE instruction when
data write is complete.
If the CLOSE instruction is not used, the data may
not be written.
• n indicates the file number.
• For details on assigning <filename>,
see Appendix 1.
.........
.........
MELSEC-Q
6 - 3

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents