11 - 168 11 - 168
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
OPEN
Instruction
OPEN
• Opens a file and enables it for input/output processing.
OPEN ”[<drive number>:][<system name>\]<file name>”
[ FOR <mode>] AS [#]<file number>
drive name
• • • •
Specify the memory card or FD drive containing the
file to be opened.
system name
• • • •
Specify the system name under which the file to be
opened is stored.
file name
• • • •
Specify the file name to be opened.
mode
• • • •
Specify to enable the sequential file for either input,
output, or append processing.
Syntax
file number
• • • •
Specify the file number of the file to be created in the
range from 1 to 8.
Examples
OPEN “2:ABCD” FOR
OUTPUT AS #1
• • • •
Opens the sequential file with the file name “ABCD”
on drive A of the console for output as file number
1.
• The OPEN instruction opens a file and enables it for input/output processing.
• It assigns a <file number> and input/output buffer to the file specified by <system name>
and <file name> and defines the mode of the file. Afterward, data input/output operations
to this file are performed by referring to this file number.
• In order to input or output data to/from a file, it is always necessary to execute the OPEN
instruction first to open the file.
• <drive number> is specified using the following numbers:
• When specifying a file in MEMORY CARD 1 drive of AD51H-S3
• When specifying a file in MEMORY CARD 2 drive of AD51H-S3
• • • • •
• • • • •
0
1
• When specifying drive A of the console
• When specifying drive C of the console
• When specifying drive D of the console
• • • • • • • • • • • • • • • • • • • • • • • • •
• • • • • • • • • • • • • • • • • • • • • • • • •
• • • • • • • • • • • • • • • • • • • • • • • • •
2
3
4
Description
If a drive number other than the ones listed above is specified, a “Bad drive number” error
occurs.
• <mode> specifies whether input or output processing can be performed to the file. Specify
one of the following options:
INPUT: Inputs data to the sequential file.
OUTPUT: Outputs data from the sequential file.
APPEND: Adds data to the end of the existing sequential file.