11 - 67 11 - 67
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
FIELD
Instruction
FIELD
• Assigns the area for the specified variable to the random file buffer.
FIELD <#> <file number> , <field length> AS <character string variable> [, <field length>
AS <character string value> ] …
file number
• • • •
Specify the file number of the random file specified
by the OPEN instruction.
field length
• • • •
Specify the number of characters to assign to the
buffer.
Syntax
character string variable
• • • •
Specify the character string variable that
corresponds to the part specified by the field length.
Examples
FIELD #1, 128 AS A$, 128
AS B$
• • • •
Defines variables A$ and B$, which are used in the
program, in the random file buffer of file number 1,
and specifies 128 bytes as the assigned number of
bytes for each.
Buffer in the random file
A$
B$
128 bytes
128 bytes
Description
• The FIELD instruction assigns an area of the specified variable in the random file buffer
that is specified by <file number>. The program writes and reads data with the random file
buffer through these variables.
• The FIELD instruction has to be executed before reading data by the GET instruction or
writing data by the PUT instruction.
• Use the LSET instruction and RSET instruction to write data to the random file buffer.
• The total number of bytes (total of <field length>) retained by one FIELD instruction should
not exceed the buffer size (256 bytes). A “Field overflow” error occurs if the total number of
retained bytes exceeds 256.
REMARK
• Multiple FIELD instructions can be executed in the random file buffer of the same
file number. Each FIELD instruction assigns the variable from the beginning of the
random file buffer, so all assignments become valid simultaneously.
• See the OPEN instruction and Chapter 6.