stoploopif
stoploopif
FORMULA

The stoploopif statement decides whether to continue with a loop or to exit the loop immediately.

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 variable Last contains the value Smith and nothing else, and false otherwise.

Description

This statement decides whether to continue with a loop or to exit the loop immediately. If the test is true, the loop will exit and the program will continue after the corresponding endloop, until or while statement. If the test is false, the loop will continue normally.

Here is an example that uses stoploopif to stop the loop when there are no more words to process.

    let wl = 0
    let n = 1
    loop
        let word = array(Notes,n," ")
        stoploopif word=""
        n = n+1
        wl = wl+length(word)
    endloop
    message "Average word length is: "+wl/n

Note: The example above was written in an older version of Panorama. The code still works, but in modern versions of Panorama this can be written in mucn more compact code (however this modern example doesn’t demonstrate the use of the stoploopif statement).

    looparray Notes," ",word
        wl = wl+length(word)
    endloop
    message "Average word length is: "+wl/wordcount(Notes)

Error Messages

STOPLOOPIF must be used between LOOP and ENDLOOP statements – The stoploopif statement cannot be used outside of a loop.

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