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
History
Version | Status | Notes |
10.0 | No Change | Carried over from Panorama 6.0. |