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


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0.