Repeat loop, L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual
Page 61

L-force | PLC Designer
What is What in PLC Designer
DMS 3.2 EN 02/2011 TD29
59
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.
REPEAT loop
The REPEAT loop is different from the WHILE loop because the break-off condition is
checked only after the loop has been executed. This means that the loop will run
through at least once, regardless of the wording of the break-off condition.
Syntax:
REPEAT
<Instructions>
UNTIL
<Boolean expression>
END_REPEAT;
The <Instructions> are carried out until the <Boolean expression> returns TRUE.