There are two versions of the Repeat statement: A conditional version and
an endless version.
1) Conditional version of the Repeat statement:
Repeat <loop-block> Until <expr> |
The conditional Repeat statement will repeat the specified loop block until
the given expression becomes true (non-zero). In other words: The block will
be looped while expr is false (zero). This is just the other way round as
the While statement behaves: While loops the code while the expression is true
and Repeat loops the code while the expression is false.
Here is an example:
i = 1
Repeat
i = i + 1
Until i = 100
|
This code counts from 1 to 100. When the loop exits, the variable i will
have the value 100.
You may also want to have a look at the documentation of the Break and Continue statements. These can be used to exit from a loop or to jump to the end of it.
2) Endless version of the Repeat statement:
Repeat <loop-block> Forever |
The endless version can be used to repeat a specific portion of code forever. You can still jump out of the loop by using the Break statement though. The endless version is mostly used in the main loop of a script that calls WaitEvent(), e.g.
Repeat
WaitEvent
Forever
|