PPWIZARD Manual
[Bottom][Contents][Search][Prev]: Rexx Conditional Logic[Next]: Rexx Parsing

Rexx Looping

You can get a (slighty out of date) regina rexx manual from http://sites.netscape.net/ssatguru, this has HTML and compiled Windows Help formats for download.

Loops are one of the complex areas of rexx and most things you will wish to do with PPWIZARD will either not require them or the simpler PPWIZARD loops will be enough.

The syntax of rexx loops is as follows:

    DO [ symbol=start   [TO  finish]  ]     [WHILE expression_w]
       [                [BY  step  ]  ]
       [                [FOR count ]  ]     [UNTIL expression_u]
    
       [ expression_c                 ]     [FOREVER           ]
    

Examples follow (these would need to be integrated with PPWIZARD using the #evaluate command :

    do 10
       /* Do something 10 times */
    end
    
    do _Count = 1 to 100
       /* Do something 100 times (Count given values 1,2,3 to 100) */
    end
    
    do _Multiple = 0 to 20 by 2.3
       /* Loop with _Multiple = all multiples of 2.3 not more than 20 */
    end
    
    do _Multiple = 0 for 6 by 5.7
       /* Loop with _Multiple = the first six multiples of 5.7 */
    end
    
    _Finished = 'N'
    do while _Finished = 'N'
       /* Set _Finished variable to 'Y' to exit loop */
    end;
    
    do until _Finished = 'Y' & _Fred <> 0
       /* Set _Finished variable to 'Y' to exit loop (_Fred must also be non zero) */
    end;
    
    do 3 until _Answer = "YES"
       /* Exits loop after 3 times or if _Answer becomes 'YES' */
    end
    
    do _Count = 1 to 10 until Fred == ""
       /* Loop 1 to 10 unless condition met */
    end
    
    do _Count = 1 to 10
       /* Looping 1 to 10 */
    
       /* Want to restart loop (don't execute following loop code)? */
       if _Restart = 'Y' then
          iterate;         /* Go back to start of loop (_Count incremented) */
    
       /* Want to exit loop early? */
       if _Flag = 'Y' | _State = 'R' then
          break;           /* Exit loop */
    end
    


[Top][Contents][Search][Prev]: Rexx Conditional Logic[Next]: Rexx Parsing

PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Tuesday January 02 2001 at 7:37am