Specifications
SIMATIC Instructions
9-150
S7-200 Programmable Controller System Manual
C79000-G7076-C233-01
For, Next
The FOR instruction executes the instructions between
the FOR and the NEXT. You must specify the index value
or current loop count (INDX), the starting value (INIT),
and the ending value (FINAL).
The NEXT instruction marks the end of the FOR loop,
and sets the top of the stack to 1.
For example, given an INIT value of 1 and a FINAL value
of 10, the instructions between the FOR and the NEXT
are executed 10 times with the INDX value being
incremented: 1, 2, 3, ...10.
If the starting value is greater than the final value, the
loop is not executed. After each execution of the
instructions between the FOR and the NEXT instruction,
the INDX value is incremented and the result is
compared to the final value. If the INDX is greater than
the final value, the loop is terminated.
For: Error conditions that set ENO = 0: SM4.3
(run-time), 0006 (indirect address)
Inputs/Outputs Operands Data Types
INDX VW, IW, QW, MW, SW, SMW, LW, T, C, AC, *VD, *AC, *LD INT
INIT VW, IW, QW, MW, SW, SMW, T, C, AC, LW, AIW, Constant, *VD,
*AC, *LD
INT
FINAL VW, IW, QW, MW, SW, SMW, LW, T, C, AC, AIW, Constant, *VD,
*AC, *LD
INT
L
A
D
S
T
L
FOR
EN
INDX
INIT
FINAL
FOR INDX,
INIT
FINAL
NEXT
NEXT
F
B
D
FOR
EN
INDX
INIT
FINAL
NEXT
222 224
333
221
ENO
ENO