The IEC 61131-3 ST WHILE statement executes a list of statements while a condition is true. The WHILE Statement has this syntax:
WHILE condition DO Statement; Statement; .. Statement; END_WHILE;
Where:
If the condition is false when the WHILE Statement starts execution, the statements inside the loop will not be executed.
If the condition is true when the WHILE Statement starts execution, the statements inside the WHILE loop are executed until the condition becomes false.
To stop the WHILE loop early (before the condition becomes false) use the EXIT Statement.
The WHILE Loop uses this logic to execute statements:
Index := 0; Sum := 0; WHILE Index < 10 DO Sum := Sum + Values[ Index ]; Index := Index + 1; END_WHILE;
IEC 61131-3 Second Edition: Table 56.7.
IEC 61131-3 Third Edition: Table 72.7.
For information about another loop type that uses a condition.
For information about another loop type that uses a fixed number of iterations.
For other Structured Text (ST) statement types.
To learn about expressions that can be used as the condition in a WHILE loop.
For the meaning of terms used in Fernhill SCADA.