REPEAT ... UNTIL

Top  Previous  Next

Use for conditional looping.

 

Syntax

<repeat_until_loop> ::=

  REPEAT 

    <statement_list>

  UNTIL <search_condition>

  END REPEAT;

 

<statement_list> ::= [<block> | <statement> [ <block> | <statement> ... ]]

 

The REPEAT UNTIL statements implements a loop that will be executed until <search_condition> evaluates to TRUE. This means the contents of the loop is executed at least once.

 

The loop can be broken without evaluating the condition with a LEAVE statement or exited with a EXIT or RETURN statement. The next iteration can be forced using a CONTINUE statement.

 

See Also

WHILE ... DO loop
FOR ... DO loop

 

Example

EXECUTE UDSBLOCK

AS

BEGIN

  I = 1;

  REPEAT

    i = i + 1;

    IF (Math.Mod(i, 2) = 0) /* check for even numbers, skip the loop if even */

    THEN CONTINUE;

    ELSE BEGIN

           /* do stuff */

         END

  UNTIL (i >= 10)

  END REPEAT;

END