7 APPLICATION INSTRUCTION
7.4 Structuring instruction
341
7
• The FOR-NEXT loop can be nested up to 16 levels.
• The FOR-NEXT loop cannot be interrupted by the I, IRET, SRET, RET, FEND, or END instruction.
• When FOR-NEXT loop is repeated many times, the operation cycle is too long, and a watchdog timer error may occur. In
such a case, change the watchdog timer time or reset the watchdog timer.
• The following programs are regarded as errors.
• To terminate the FOR to NEXT instruction loop halfway, use the BREAK instruction. (Page 342
Forcibly terminating the FOR to NEXT instruction loop)
When the NEXT instruction is located before FOR No NEXT instruction
When the number of FOR instructions is not equivalent to the number of
NEXT instructions
When the NEXT instruction is located after the FEND or END instruction
Error code
(SD0/SD8067)
Description
3340 After the FOR instruction is executed, the END or GOEND instruction is executed before the NEXT instruction is executed.
3361 When the FOR instruction is nested, the 17th level is executed.
FOR
FOR
FOR
NEXT
NEXT
NEXT
FOR
FOR
FOR
NEXT
NEXT
NEXT
3rd level
2nd level
1st level
2nd level
1st level
1st level
FOR
NEXT
NEXT
FOR
Not programmed