6 - 7 6 - 7
MELSEC-Q
6 I/O Processing of Data Files
6.3 Random File I/O Procedures
Random files can be used to perform input and output once they are opened. The
following explains how to input and output the random file data:
Data
LSET/RSET instructions
Random file
MEMORY CARD
A6MEM-512KA-W
Record number 1
Record number 2
Record number 3
G E T / P U T i n s t r u c t i o n s
Variable name and size
are defined with
the FIELD instruction
$
$
File buffer
LET instruction
• A random file manages data by separating each record. Numbers are assigned to
each of the records. When data is read or written, the record number is designated
and the data input/output are performed with the file buffer. The numbers placed on
the blocks are referred to as "Record numbers."
• "File buffer" acts as a window when performing I/O with random files. The character
variables defined by the FIELD instruction are used during I/O for the "file buffer."
Therefore, data written into the file buffer must all be character data.
For example, when numeric data is being written, the STR$ function is used to
convert them into character data or they are converted using the following functions
below. Then, they are placed in the file buffer by the LSET or RSET instruction and
written into the file by the PUT instruction.
Integer Data
MKI$(I)
(Becomes 2 bytes of character data)
Single-precision Data MKS$(R)
(Becomes 4 bytes of character data)
Double-precision Data MKD$(D)
(Becomes 8 bytes of character data)
• When writing data into a random file, the data that is to be written is stored in the "file
buffer" using the LSET and RSET instructions. Then, it is written in an arbitrary
record <record number> by the PUT instruction.