Previous Topic: &DOM

Next Topic: &DOWHILE


&DOUNTIL

&DOUNTIL builds a conditional loop with a test at the bottom.

&DOUNTIL expression [ AND | OR expression .... ]

The &DOUNTIL loop is executed repetitively until the conditions specified in the expressions become true. When the test succeeds, execution continues past the &DOEND statement paired with the &DOUNTIL statement.

Operands:

expression

This expression acts as the test for the &DOUNTIL condition. The expression is evaluated at the bottom of the loop:

Compounded expressions can be used, joined with AND or OR operators, but parentheses cannot be used.

Examples: &DOUNTIL

&DOUNTIL &A = 10 OR &B GT &A   
   &B = &B + 2
   &A = &A + 1
&DOEND

This simple loop is repeated until &A reaches a value of 10, or until &B reaches a value greater than &A, whichever comes first.

&GOSUB .GETMSGS
&MSG0 = &STR the following messages were received
&CNT = 0
&DOUNTIL &CNT GE &MSGCNT
  &WRITE DATA = &MSG&CNT
  &CNT = &CNT + 1
&DOEND
&WRITE DATA=**End of messages**

This example shows a routine for writing a stream of messages set up by the .GETMSGS subroutine.

Note: The loop always executes once, therefore only the title and the end messages will be written if &MSGCNT=0.

Notes:

&DOUNTIL groups must be terminated by an &DOEND statement, that is, &DOUNTIL and &DOEND statements must be paired. Unbalanced pairs cause syntax errors at load time.

&LOOPCTL is provided to control runaway looping. Iterations of loops during &DOWHILE and &DOUNTIL processing are included in &LOOPCTL calculations.

More information:

&DOWHILE

&DO