until
until
FORMULA

The until statement is used at the end of a loop, and can control how many times the loop is executed.

Parameters

This statement has one parameter:

formula – is a formula that should result in a true (-1) or false (0) answer. Usually the formula is created with a combination of comparison operators (=, <>, etc.) and Boolean operators (and, or, etc.) For example the formula `Last="Smith"` will be true if the field or variables Last contains the value Smith, and false if it contains any other value.

An alternate option for this parameter is a number specifying the number of times to loop. To use this option the formula must be a single integer constant, for example 6 or 25. The formula cannot contain any operators, in other words, you cannot calculate the number of times to loop (if you need to do this, use the for statement).

Description

The until statement may be used at the end of a loop (see the Loop statement). Unlike the endloop statement, the until statement makes a decision whether to jump back up to the top of the loop, or to continue with the next statement after the loop. The formula in the until statement is evaluated each time Panorama reaches the end of the loop. Panorama will continue looping as long as the result of the formula remains false. If the result of the formula is true, the loop stops and the procedure continues with the next statement after the until statement.

This example adds 10 new records to the current database.

    local NewCount
    NewCount=10
    loop
        NewCount=NewCount-1
        addrecord
    until NewCount=0

The until statement also has an alternate usage that allows you to directly specify the number of times the statements in the loop will be repeated. To do this, simply supply a single integer number as the formula. Here is a simpler example that also adds 10 records to the database.

    loop
        addrecord
    until 10

To use this option the formula must be a single constant number with no calculations, for example 12 is ok but `6*2` will not work, nor will `until VarName` where VarName is a variable containing a numeric value.

    // THIS EXAMPLE DOES NOT WORK!!
    let NewCount=10
    loop
       addrecord
    until NewCount

If necessary, you can use the loopindex statement to find out how many times the loop has repeated. Like the previous example, this procedure will add ten records to the database. However, in this case, the Num field in the new records will be assigned a number from 1 to 10 as the records are added.

    loop
        addrecord
        loopindex Num
    until 10

Error Messages

LOOP without ENDLOOP – Each UNTIL statement must be paired with a corresponding LOOP, statement. If this error message appears, the necessary statement starting the loop has not been included.

See Also

- endloop -- is used at the end of a loop.
- for -- is used at the beginning of a loop that loops a fixed number of times.
- info("timelimitremaining") -- returns the amount of time available (in seconds) before a loop will time out.
- loop -- is used at the beginning of a loop.
- looparray -- is used at the beginning of a loop that loops over the elements of an array.
- loopdataarray -- is used at the beginning of a loop that loops over the elements of a data array.
- loopindex -- allows a procedure to determine how many times a loop has been repeated.
- loopwhile -- is used at the beginning of a loop.
- Preventing Endless Loops -- setting up a timeout limit to prevent endless loops.
- repeatloopif -- decides whether to continue with a loop or to start over again from the top.
- stoploopif -- decides whether to continue with a loop or to exit the loop immediately.
- timelimit -- specifies the maximum time a procedure can continue to run after this statement.
- while -- is used at the end of a loop, and can control how many times the loop is executed.

History

Version | Status | Notes
10.0 | No Change | Carried over from Panorama 6.0.