See Also: Boolean Expressions, Execution Control Commands, For, Loop, Until, While, Break, Boolean
Executes a repeating block of code.
Repeat
Until {Boolean-expression}
Until sends execution back to the last previous Repeat command until the {Boolean-expression} becomes true. When {Boolean-expression} becomes true, execution proceeds to the command next following the Until command.
A Repeat ... Until block will still execute once even if {Boolean-expression} is True, unless you program the Repeat command with conditionals to make it, also, subject to {Boolean-expression}.
This sample shows how to loop through table rows using the global record buffer. It assumes that Index 1 of the Customer table is Customer_Number and unique (the only segment in this index).
Clear Customer
Repeat
Find GT Customer By 1 // Index 1 = Customer_Number
If (Found) Begin
// do something with the customer record
End
Until (not(Found))
Send ShowDetails
The function method InventoryCheck executes repeatedly until the Boolean variable bFinished is true. Execution then continues on to the next command.
Boolean bFinished
Repeat
Get InventoryCheck To bFinished
Until bFinished
In this example, 1 is added to the variable iPlayers repeatedly, until it is greater or equal to 10. Keep in mind that iPlayers starts out at 0, since it is not specifically initialized to a value.
Integer iPlayers
Repeat
increment iPlayers
Until (iPlayers >= 10)
Repeat loops may also be terminated with loop (although this technique is unusual).
You may place Repeat ... Until blocks inside other looping blocks, up to a limit of 40. And you may freely intermingle the various types of loops. But you may not overlap them—you must end the innermost block first, then the next innermost, and so on.
You may exit from the middle of a loop by using break. If your loop is within a function or procedure (which it typically is), it may be terminated with function_return or procedure_return, which also terminate the function or procedure.
Statements inside blocks are usually indented to make the blocks more readable.
Repeat is an unconditional initiator. For a conditional initiator, use while.