The Repeat command repeats a group of commands until [Condition] is true.
Unlike While [Condition] which tests the condition as soon as it is passed in the program, Repeat [Conditon] is tested when End is encountered.
Because of this, the instructions inside the Repeat loop are always run at least once.
Repeat can be nested.
Repeat 0:commands:End is used, the repeat-end block will loop forever, since in boolean 0 equals false
This program asks to
PLEASE ENTER 5. Once 5 is entered, it will then display
YOU CHOSE 5.
Note: Because Repeat tests X=5 once it hits the end there is no need to declare 0→X at the start.
See Also Edit
- GetKey (examples with Repeat)