9 for loop, For loop, Drive plc developer studio – Lenze DDS v2.3 User Manual
Page 46

Drive PLC Developer Studio
Programming languages
4-8
l
DDS EN 2.3
4.3.9
FOR loop
Use the FOR loop to program repetitive procedures.
Syntax:
INT_Var :INT;
FOR
END_FOR
;
•
The part in curly brackets {} is optional.
•
The
the
•
A check is performed before the
will never be executed if
•
Whenever the section
by
•
The step size can have any integer value. If no other step size is specified, step size 1 will be
used. The loop must terminate because
•
If
loop is counted in opposite direction.
•
If
will not be executed.
Example:
FOR
Counter:=1 TO 5 BY 1 DO
Var1:=Var1*2;
END_FOR
;
Res:=Var1;
Assuming that the variable Var1 has been pre-assigned value 1, it will be 32 after the FOR loop.
Caution!
must not be the limit value of the counter
If, for instance, the variable Counter is of type SINT,
otherwise the loop would be endless.
After completion of the FOR loop, Counter has a value 6.
Show/Hide Bookmarks