REPEAT INDEX

REPEAT _ _ _ _ _ _ _ _ _ _ _ _ command

The repeat command causes repeated execution of a statemen t until

the given condition is found to be true. The statement is always executed at least once.

syntax:

repeat<statement> until <condition>

<statement> can be a single statement, group statement, or a begin...end block. <condition> must be a logical operator that evaluates to true or nil.

examples:


<<m := 4; repeat <<write 100*x*m;m := m-1>> until m = 0>
>;
			 


  400*X
  300*X
  200*X
  100*X



<<m := -1; repeat <<write m; m := m-1>> until m <= 0>
>;
			 


  -1

repeatmust always be followed by an until with a condition. Be careful not to generate an infinite loop with a condition that is never true. In the second example, if the condition had been m = 0, it would never have been true since m already had value -2 when the condition was first evaluated.