Chapter 8. Structured Text (ST) Programming
GFK-2950C
February 2018
379
8.2.7
WHILE Statement
The WHILE loop repeatedly executes (iterates) a statement list contained within the
WHILE…END_WHILE construct as long as a spe
cified condition is TRUE (1). It checks the condition
first, then conditionally executes the statement list. This looping construct is useful when the
statement list does not necessarily need to be executed.
Format
WHILE <BooleanExpression> DO
<StatementList>;
END_WHILE;
Where:
BooleanExpression
Any expression that resolves to a Boolean value.
StatementList
Any set of Structured Text statements.
Operation
If BooleanExpression is FALSE (0), the loop is immediately exited; otherwise, if the
BooleanExpression is TRUE (1), the StatementList is executed and the loop repeated. The statement
list may never execute, since the Boolean expression is evaluated at the beginning of the loop.
Note:
It is possible to create an infinite loop that will cause the watchdog timer to expire. Avoid
infinite loops.
Example
The following code fragment increments J by a value of 2 as long as J is less than or equal to 100.
WHILE J <= 100 DO
J := J + 2;
END_WHILE;
Summary of Contents for PACSystems RX7i
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451...