Description
The WHILE
instruction has the effect that a sequence of instructions
will be executed repeatedly until its related Boolean expression is
0 (false). If the expression is false right from the start, the group
of instructions will not be executed at all.
The DO
instruction identifies the end of the repeat definition and the
beginning of the instruction(s).
The occurrence may be terminated
early using the EXIT
.
The END_WHILE
instruction
marks the end of the instruction(s).
In the following cases WHILE
may not be used as it can created an endless loop
which causes the program to crash:
WHILE
may not be used for synchronization between processes, e.g. as a "Waiting Loop" with an externally defined end condition.WHILE
may not be used in an algorithm, as the completion of the loop end condition or execution of anEXIT
instruction can not be guaranteed.
Example WHILE...DO...END_WHILE
x := 1;
WHILE x <= 100 DO
x := x + 4;
END_WHILE ;