while
while
FORMULA

The while 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 the keyword `FOREVER`. If this keyword is used, the loop will repeat forever unless a StopLoopIf statement exits the loop.

Description

The while statement is used at the end of a loop (see the Loop statement). Unlike the endloop statement, the while 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 while 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 true. If the result of the formula is false, the loop stops and the procedure continues with the next statement after the while statement.

This example adds 10 new records to the current database.

    local NewCount
    NewCount=10
    loop
        NewCount=NewCount-1
        addrecord
    while NewCount>0

Error Messages

WHILE does not have a matching LOOP statement –

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.
- until -- 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.