Wednesday, July 12, 2017

REXX: Looping in REXX

A loop is a repetitive execution of a set of statements until some conditions are met.

Do I = 1 To 10
   Say "Value of I :" I
End

LEAVE verb leaves the immediate loop after execution.

Do I = 1 To 10 
   If I = 5 then LEAVE
   Say "Value of I :" I
End 

Result would be: 
Value of I : 1
Value of I : 2
Value of I : 3
Value of I : 4

ITERATE verb ignores the statement following it and starts the next iteration in the loop

Do I = 1 To 10 
   If I = 5 then ITERATE
   Say "Value of I :" I
End 

Result would be: 
Value of I : 1
Value of I : 2
Value of I : 3
Value of I : 4
Value of I : 6
.
.
.
Value of I : 10

No comments:

Post a Comment

Featured Post

REXX Skeleton: Submitting jobs through Rexx

Submitting jobs through REXX and reading the spool through REXX gives us immense potential to automate many manual activities in mainframes....