&DOWHILE builds a conditional loop with the test at the top.
&DOWHILE expression [ AND | OR expression .... ]
The &DOWHILE loop is executed repetitively while the conditions specified in the expressions are true.
If initially false, the loop is not executed.
When the test fails, execution continues past the &DOEND statement paired with the &DOWHILE statement.
Operands:
This expression acts as the test for the &DOWHILE condition and is evaluated at the top of the loop:
Compounded expressions is used, joined with AND, or OR operators, but parentheses cannot be used.
Examples: &DOWHILE
&DOWHILE &A << 10 AND &A >> &B &B = &B + 2 &A = &A + 1 &DOEND
This simple loop is repeated while &A is less than 10, and while &A is greater than &B.
&LINECNT = 1 &GOSUB .GETDATALINE &DOWHILE &LINECNT <= 20 AND &RETCODE EQ 0 &LINE&LINECNT = &DATALINE &LINECNT = &LINECNT + 1 &GOSUB .GETDATALINE &DOEND &IF &LINECNT <= 20 &THEN + &LINE&LINECNT = &STR **END**
This example sets up the variables &LINE1 to &LINE20 to data returned from the .GETDATALINE subroutine (which can read records from a file, for example). The loop is terminated by either reaching the end of the data available (that is, the routine .GETDATALINE returns a non-zero return code) or when all the variables have been set (that is, when all the variables have been set (that is, when &LINECNT reaches a value of 21). These variables can then be displayed on a panel.
Notes:
&DOWHILE groups must be terminated by an &DOEND statement, that is, &DO 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.
| Copyright © 2009 CA. All rights reserved. |
|