384
FOR, NEXT
Operation Error
(1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into
SD0.
Program Example
(1) The following program executes the FOR to NEXT loop when X8 is OFF, and does not execute it when X8 is ON.
[Ladder Mode]
[List Mode]
Remark
1. To force an end to the repetitious execution of the FOR to NEXT loop during the execution of the loop, insert a BREAK
instruction. See Page 385, Section 7.6.2 for details concerning the use of the BREAK instruction.
2. Use the EGP/EGF instruction to perform the pulse operation of an index-modified program between the FOR and NEXT
instructions. Note, however, that rise and fall instructions are not available on the operation output side. Refer to Page 137,
Section 5.2.5 for details of the EGP/EGF instruction. The program samples are shown below:
3. Branching into a FOR to NEXT loop using a JMP or other branch instruction from the outside of the FOR to NEXT loop
is not possible.
Error
code
Error details
Q00J/
Q00/
Q01
QnH
QnPH QnPRH
QnU
LCPU
4200
After the FOR instruction was executed, the END, FEND, or GOEND
instruction was executed prior to the NEXT instruction.
The STOP instruction is in process between the FOR and the NEXT
instructions.
4201
The NEXT instruction was executed prior to the FOR instruction.
4202
The 17th FOR instruction was executed when the FOR instruction has
been nested.
Step
Instruction
Device