REPEAT statement

The REPEAT statement processes a sequence of statements, then evaluates the condition expression.

Syntax

Read syntax diagramSkip visual syntax diagramRepeatUntilLabel:RepeatUntilLabel
RepeatUntil
Read syntax diagramSkip visual syntax diagramREPEATstatementsUNTILconditionENDREPEAT

The REPEAT statement repeats the steps until condition is TRUE. Ensure that the logic of the program is such that the loop terminates. If the condition evaluates to UNKNOWN, the loop does not terminate.

If present, the Label gives the statement a name. This has no effect on the behavior of the REPEAT statement, but allows statements to include ITERATE and LEAVE statements or other labelled statements, which in turn include ITERATE and LEAVE. The second Label can be present only if the first Label is present and, if it is, the labels must be identical. Two or more labelled statements at the same level can have the same label, but this partly negates the advantage of the second Label. The advantage is that it unambiguously and accurately matches each END with its REPEAT. However, a labelled statement within statements cannot have the same label because this makes the behavior of the ITERATE and LEAVE statements ambiguous.

Example

DECLARE i INTEGER;
SET i = 1;
X : REPEAT
  ...
  SET i = i + 1;
UNTIL
  i>= 3
END REPEAT X;