NetRexx provides a selection of control statements, whose form was chosen for readability and similarity to natural languages. The control statements include IF... THEN... ELSE (as in the 'greet' example) for simple conditional processing:
if ask='Yes' then say "You answered Yes" else say "You didn't answer Yes"
SELECT... WHEN... OTHERWISE... END for selecting from a number of alternatives:
select when a>0 then say 'greater than zero' when a<0 then say 'less than zero' otherwise say 'zero' end
DO... END for grouping:
if a>3 then do say 'A is greater than 3; it will be set to zero' a=0 end
and LOOP... END for repetition:
loop i=1 to 10 /* repeat 10 times; I changes from 1 to 10 */ say i end
The LOOP statement can be used to step a variable TO some limit, BY some increment, FOR a specified number of iterations, and WHILE or UNTIL some condition is satisfied. LOOP FOREVER is also provided. Loop execution may be modified by LEAVE and ITERATE statements that significantly reduce the complexity of many programs.
[ previous section | contents | next section ]
From 'nrover.doc', version 1.113.
Copyright(c) IBM Corporation, 1996, 1997. All rights reserved. ©