Scope/Function names and labels: Difference between revisions
Content added Content deleted
m (added whitespace before the TOC, added a Task (bold) header.) |
m (→{{header|REXX}}: added/changed comments and whitespace, changed indentations.) |
||
Line 462: | Line 462: | ||
<br>(all of the above are normally contained on one line (record), but may (syntactically) be continued by the normal REXX rules for continuation. |
<br>(all of the above are normally contained on one line (record), but may (syntactically) be continued by the normal REXX rules for continuation. |
||
<br><br>Any label can be referenced from anywhere in the REXX program (global scope). |
<br><br>Any label can be referenced from anywhere in the REXX program (global scope). |
||
<br><br>Multiple labels (with the same name) are not considered an error in the REXX language; the first label found is used. |
<br><br>Multiple labels (with the same name) are not considered an error in the REXX language; the first label found (topmost) is used. |
||
<lang rexx>/*REXX program demonstrates use of labels and a CALL statement. */ |
<lang rexx>/*REXX program demonstrates the use of labels and also a CALL statement. */ |
||
⚫ | |||
zz=4 |
|||
signal do_add /*transfer program control to a |
signal do_add /*transfer program control to a label.*/ |
||
ttt=sinD(30) /*this REXX statement is never executed |
ttt = sinD(30) /*this REXX statement is never executed*/ |
||
/* [↓] Note the case doesn't matter. |
/* [↓] Note the case doesn't matter. */ |
||
DO_Add: /*coming here from the SIGNAL statement*/ |
|||
say 'calling the sub: add.2.args' |
say 'calling the sub: add.2.args' |
||
call add.2.args 1,7 /*pass two arguments: 1 and a 7 |
call add.2.args 1, 7 /*pass two arguments: 1 and a 7 */ |
||
say 'sum =' result /*display the result from the function.*/ |
|||
say 'sum =' result |
|||
exit /*stick a fork in it, |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
/*────────────────────────────────subroutines (or functions)────────────*/ |
|||
add.2.args: |
add.2.args: procedure; parse arg x,y; return x+y /*first come, first served ···*/ |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
'''output''' |
'''output''' |
||
<pre> |
<pre> |