previous  next
Repeat
Syntax
Repeat C Until B
Repeat C EndRepeat

where C is a sequence of commands and B is a boolean expression.
Summary
loop command
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, the command sequence C is repeated until a 'Break' or
'Return' is encountered within C.

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;
Repeat 
  N := N+1;
  PrintLn(N);
  Return If N = 5;
EndRepeat;
1
2
3
4
5

-------------------------------
See also: