6 - 3 6 - 3
MELSEC-Q
6 I/O Processing of Data Files
6.2 Sequential File I/O Procedures
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.
PRINT #n, <write data>,
PRINT #n, USING " ", <write data>,
OPEN "<filename>" FOR OUTPUT AS #n
2) Write the data in the file
3) Close the file
CLOSE #n
• n indicates the file number.
• For details on assigning <filename>,
see Appendix 1.
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.
………
………
………
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.
INPUT #n, <variable to store the data read>,
LINE INPUT #n, <variable to store the data read>,
OPEN " <filename> " FOR INPUT AS #n
2) Read the data from the file.
3) Close the file.
CLOSE # n
………
………
Содержание 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...