January 2012 8.35 Program Structures 1747
8.35.3 WHILE ... ENDW structure
The WHILE ... ENDW structure repeats a program sequence if a condition is
fulfilled. Under no circumstances can you wait with this structure in the cyclic
PLC program for the occurrence of an external event! The following
commands are available:
WHILET (WHILE TRUE):
Run the sequence if logic accumulator = 1.
WHILEF (WHILE FALSE):
Run the sequence if logic accumulator = 0.
ENDW (END WHILE):
End of the program sequence, return to the beginning
The control runs a WHILE ... ENDW loop only if at the beginning the WHILE
condition is fulfilled. Before the ENDW statement you must reproduce the
condition for execution. The control generates two internal labels for the
WHILE ... ENDW structure. The condition can also be produced in a way
different from before the WHILE statement!
Function STL
Load marker 100 into the logic accumulator; create
condition for 1st WHILE scan.
L M100
Run the following code if logic accumulator = 1 WHILET
Program code for logic accumulator = 1
Produce the condition of repeated execution: Load
marker 101 in the logic accumulator and gate the
content of marker M102 with AND.
L M101
A M102
Jump back to the WHILE request ENDW