[Next] [Up] [Previous]

The WHILE Statement

The WHILE statement has the form

       WHILE logical-expression,sequence

where sequence is one or more executable statements enclosed by statement brackets.

Its action is to cause the statements within sequence to be continuously executed as long as logical-expresssion has the value of true (_T).

If the logical-expression is false upon entry into the WHILE statement, the sequence is never executed.

The comma can be commented as @DO, or replaced by &'DO'`.

If the sequence argument is omitted, the statement must be numbered, and causes a REPEAT statement referring to that number to transfer control to the statement following the WHILE statement if the expression in logical-expression is true. A WHILE statement with the sequence omitted essentially does nothing at execution time the first time it is encountered, so the code following it is always executed at least once. Another reason for this is that more than one REPEAT statement can refer to the same WHILE statement, and so the WHILE statement cannot be the one to perform the decision about repeating the loop.

[Next] [Up] [Previous]