While Statement - GE PACSystems RX7i Cpu Programmer's Reference Manual

Hide thumbs Also See for PACSystems RX7i:
Table of Contents

Advertisement

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 specified 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
StatementList
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;
GFK-2950C
Any expression that resolves to a Boolean value.
Any set of Structured Text statements.
February 2018
Chapter 8. Structured Text (ST) Programming
379

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pacsystems rx3iPacsystems rsti-ep

Table of Contents