While loop, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual
Page 766

L-force | PLC Designer
General Editors
764
DMS 4.1 EN 03/2011 TD29
Let us assume that the default setting for Var1 is "1". Then it will have the value 32
after the FOR loop.
Note: If
example if Counter - used in the example shown above - is of type SINT and if
be equal to the limit value of the counter !
Extension to the IEC 61131-3 standard (ExST):
The CONTINUE instruction can be used within a FOR loop.
WHILE loop
The WHILE loop can be used like the FOR loop with the difference that the break-off
condition can be any Boolean expression. This means you indicate a condition which,
when it is fulfilled, the loop will be executed.
Syntax:
WHILE
END_WHILE;
The
returns TRUE. If the
the
value FALSE, then the
time delay.
Note: The programmer must make sure that no endless loop is caused. He does this
by changing the condition in the instruction part of the loop, for example, by
counting up or down one counter.
Example:
WHILE Counter<>0 DO
Var1 := Var1*2;
Counter := Counter-1;
END_WHILE
The WHILE and REPEAT loops are, in a certain sense, more powerful than the FOR loop
since one doesn't need to know the number of cycles before executing the loop. In
some cases one will, therefore, only be able to work with these two loop types. If,
however, the number of the loop cycles is clear, then a FOR loop is preferable since it
allows no endless loops.
Extension to the IEC 61131-3 standard (ExST):
The CONTINUE instruction can be used within a WHILE loop.