|
NetRexx Overview, version 2.02
Copyright (c) IBM Corporation, 2001. All rights reserved. © | 22 May 2001 |
| [previous | contents | next] |
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
select case i+1
when 1 then say 'one'
when 1+1 then say 'two'
when 3, 4, 5 then say 'many'
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:
/* repeat 10 times; I changes from 1 to 10 */
loop i=1 to 10
say i
end i
The loop instruction 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, and
loop over can be used to work through a collection of
variables.
Loop execution may be modified by leave and iterate instructions that significantly reduce the complexity of many programs.
The select, do, and loop constructs also have the ability to catch exceptions that occur in the body of the construct. All three, too, can specify a finally instruction which introduces instructions which are to be executed when control leaves the construct, regardless of how the construct is ended.
From
The NetRexx Language by
Mike Cowlishaw,