Flow-control structures: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: changed a REXX program example. -- ~~~~) |
(→leave: re-instated REXX program.) |
||
Line 1,709: | Line 1,709: | ||
===leave=== |
===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. |
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 rexx> 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=== |
===raising conditions=== |