Skip to content

Execution control constructs

Selection control structure

The if construct:

IF (logical expression 1) THEN
   block 1
{ELSE IF (logical expression 2) THEN
   block 2

ELSE IF (logical expression n) THEN
   block n}
{ELSE
   block n + 1}
END IF
  • One block at most is executed.

  • Note the compulsory parentheses around each logical expression.

Iteration control structure

The « do » loop

DO variable = expr1, expr2{, expr3}
   block
END DO
  • The variable must be of integer type and it is forbidden to modify it inside the loop.

  • The 3 expressions must be of integer type.

    • expr1 is the initial value.

    • expr2 is the limiting value.

    • expr3 is the increment (must be ≠ 0 if present).

  • The 3 expressions are evaluated only once, when the do construct is encountered.

  • The default value of the increment is 1.

  • The number of iterations can be 0 (this does not produce a run-time error). For example if expr2 < expr1 and increment is 1.

The « do while » construct

DO WHILE (condition)
   block
END DO

Note that the parentheses delimiting the condition are compulsory.