Jump to content

Flow-control structures: Difference between revisions

→‎leave: re-instated REXX program.
m (→‎{{header|REXX}}: changed a REXX program example. -- ~~~~)
(→‎leave: re-instated REXX program.)
Line 1,709:
===leave===
The '''leave''' statement transfer control to the next REXX statement following the   '''end'''   statment of the current   '''do'''   loop.   The '''leave''' statement can also specify which '''do''' loop is to be left if the '''do''' loop has a named variable.
<lang rexx></lang> do j=1 to 10
say 'j=' j
if j>5 then leave
say 'negative j=' (-j)
end /*j*/
 
say 'end of the DO loop for j.'
 
ouch=60
sum=0
do k=0 to 100 by 3
say 'k=' k
do m=1 to k
if m=ouch then leave k
sum=sum+m
end /*m*/
end /*k*/
say 'sum=' sum</lang>
 
===raising conditions===
Cookies help us deliver our services. By using our services, you agree to our use of cookies.