loopwhile
FORMULA

The loopwhile statement is used at the beginning of a loop.


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


Description

The loopwhile statement is used at the beginning of a loop that iterates as long as a formula is true. As soon as the formula is false, the loop stops. In fact, if the formula is false before the loop begins, the statements in the loop are never executed. The end of a loopwhile loop is always an endloop statement.

This example takes a string of text and makes it shorter each time through the loop. When the text is all gone, the loop stops.

local text
text="abcd"
loopwhile text<>""
   message text
   text=text[1,-2]
endloop

With the text set to abcd, this loop will run 4 times, with the following results:

abcdabcaba

If the text variable was empty (""), the statements in the loop would be skipped entirely, and no message would appear at all.


Error Messages

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


See Also


History

VersionStatusNotes
10.0NewNew in this version