11 - 19 11 - 19
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
Description
• The CHAIN instruction reads a different program (subsequent program), which is separate
from the program currently residing on the memory (current program), to the area of the
same BASIC number, and hands the variables and their contents of the current program
over to the subsequent program, then have the newly read program start its execution. In
this way, a large program can be split and executed continuously.
• For details of specifying <drive number>; <system name> \ <file name> to read a new
program, see Section 3.3.1.
• <line number 1> is the execution starting line of the newly read program and the program
is started from the specified line number by specifying this line number. The program
starts from the first line if <line number 1> is omitted.
<line number 1> may not be specified by a label. In addition, it is not a subject of line
number change by the RENUM instruction.
• Hand over the variables of the current program (current program) to the newly read
program (subsequent program) as follows:
1) To hand over all variables from the current program to the subsequent program,
specify the ALL option in the CHAIN instruction.
2) To hand over only a part of variables from the current program to the subsequent
program, omit the ALL option in the CHAIN instruction and specify the variables to
hand over separately by using a COMMON instruction.
For details of the COMMON instruction, see the COMMON item.
• The following restrictions apply for handing over the variables:
1) The user-defined functions that were defined by the DEF FN function cannot be
handed over.
2) The constant types defined by the DEFDBL, DEFSNG, DEFINT, and DEFSTR
instructions can be handed over only when the MERGE option is specified.
To specify the MERGE option
• If the MERGE option is specified, the subsequent program is merged into the current
program and executed. This option enables to replace the internal subroutine. In order to
replace, it is necessary to specify which part of the current program to erase and the
subsequent program to merge. Specify this with the DELETE option. In other words, <line
number 2> - <line number 3> of the current program is deleted and the subsequent
program is inserted into that part.
If both MERGE and DELETE options are specified, the program lines are reordered
depending on the line numbers of the merging program and merged program.
• Be sure to specify the MERGE option when the DELETE option is specified.
REMARK
See Section 3.15.