WHILE Statement

<while statement>

── WHILE ── <Boolean expression> ── DO ── <statement> ─────────────────┤

Explanation

The WHILE statement enables you to perform a statement while a condition is TRUE.

The Boolean expression is evaluated; if the result is TRUE, the statement following the DO is executed. This sequence of events continues until the Boolean expression becomes FALSE or the statement following the DO transfers control outside itself.

Note: If the Boolean expression never evaluates to FALSE, and no GO statement is used to transfer control outside, the WHILE statement can result in an infinite loop.

If the same PROCESS statement is executed repeatedly by a WHILE statement, a run-time error might result. This can occur because the asynchronous task initiated by an earlier pass through the WHILE statement might still be running, and a given task variable can only be used by one task at a time.

Example

The following is an example of the WHILE statement:

WHILE T(TASKVALUE) NEQ 1 DO
  BEGIN
  INITIALIZE(T);
  RUN X[T];
  END;