DGL Statement Reference : WHILE/LOOP

WHILE/LOOP

Description
Provides iterative execution of DGL statements. The execution of statements is determined by evaluation of the boolean_expression.
The statements are executed until the expression evaluates to false. For example:

WHILE a > b LOOP
.
.
b := b + k;
.
.
END LOOP;

The statements between the keywords LOOP and END LOOP are executed as long as a is greater than b.
Assume that b changes its value inside the loop and in one of the iterations the expression a > b becomes false. In the next iteration, the expression is examined and, because a > b is now FALSE, the execution of template statements continues with the first statement after the END LOOP.
Syntax
WHILE boolean_expression LOOP
statements
END LOOP;
Parameters
 
Notes
The value of boolean_expression must be altered within the loop, or an EXIT statement must be executed in order to terminate the loop.
Example
WHILE count < 25 LOOP
num_control := alpha / 5;
WRITE (count, num_control, ’\n’;
alpha := synch +7;
count := count + 1;
END LOOP;
See Also