up previous next
Repeat

loop command
Syntax
          
Repeat C Until B

where C is a sequence of commands and B is a boolean expression.

          

Description
In the first form, the command sequence C is repeated until B evaluates to False. Unlike the While command, C is executed at least once. Note that there is no EndRepeat following B. In the second form, ending with EndRepeat is obsolescent from version 4.7.5, and can be trivially substituted with While True Do ...... EndWhile

Example
  Define GCD_Euclid(A, B)
    Repeat
      R := Mod(A, B);
      A := B;
      B := R;
    Until B = 0;
    Return A;
  EndDefine;

  GCD_Euclid(6,15);
3
-------------------------------
  N := 0;
  While True Do 
    N := N+1;
    PrintLn N;
    If N = 5 Then Return; EndIf;
  EndWhile;
1
2
3
4
5

-------------------------------


See Also