6 - 2 6 - 2
MELSEC-Q
6 I/O Processing of Data Files
6
6.1 File Numbers
BASIC can use up to 8 strings of data files per program simultaneously.
In BASIC data file I/O instructions, file numbers are used to specify which of these 8
data files will be input and output.
(1) The correspondence between data files and file numbers
Data files and file numbers of which I/O is performed are assigned
correspondence by the file numbers that are designated when the data files are
opened with the OPEN instruction.
Example
2) OPEN " 0:B-10. DAT" FOR INPUT AS # 3
When data is being input from a sequential
file "0: B-10.DAT," #3 will be used as the file
number.
3) OPEN " 1:R-2. DAT" AS # 2
For random files
When data is being input and output from a
random file "1: R-2.DAT," #2 will be used as the
file number.
1) OPEN " 0:A-1. DAT" FOR OUTPUT AS # 1
For sequential files
When data is being output to a sequential
file "0: A=1.DAT," #1 will be used as the file
number.
(2) File numbers in I/O instructions
In I/O instructions to be used with data files, the data files to which the I/O is
being performed is directly not specified. File numbers are used instead.
I/O will be performed on data files that are corresponded using the OPEN
instruction by designating a file number.
Example
Assuming that 1), 2), and 3) of (1) are already running:
1)' PRINT # 1. " MITSUBISHI"
2)' INPUT # 3. A$
3)' FIELD # 2. R$ AS 100
"MITSUBISHI" is output to sequential file
"0:A-1.DAT"
Data is input to variable A$ from the
sequential file "0:B-10.DAT."
The file buffer of random file "1:R-2.DAT"
is defined.