Document Templates : DGL Statements : Control Flow Statements : WHILE/LOOP Statement

WHILE/LOOP Statement

Statement Syntax:

WHILE boolean_expression LOOP
statements
END LOOP ;

The WHILE/LOOP construct is used to iteratively execute 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, since a > b is now false, the execution of template statements continues with the first statement after the END LOOP.