Scope/Function names and labels: Difference between revisions

m
→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations.
m (added whitespace before the TOC, added a Task (bold) header.)
m (→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations.)
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><br>Any label can be referenced from anywhere in the REXX program &nbsp; (global scope).
<br><br>Multiple labels (with the same name) are not considered an error in the REXX language; &nbsp; the first label found (topmost) is used.
<lang rexx>/*REXX program demonstrates the use of labels and also a CALL statement. */
blarney = -0 /*just [↑] a deadblarney code,& neverbalderdash XEQedstatement*/
zz=4
signal do_add /*transfer program control to a label.*/
ttt = sinD(30) /*this REXX statement is never executed.*/
/* [↓] Note the case doesn't matter. */
do_AddDO_Add: /*coming here from the SIGNAL statement.*/
 
say 'calling the sub: add.2.args'
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, 'cause we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*────────────────────────────────subroutines (or functions)────────────*/
add.2.args: procedure; parse arg x,y; return x+y /*first come, first served ···*/
add.2.args: say 'Whoa Nelly!! Has the universe run amok?' /*didactic, but never executed*/
 
add.2.args: return arg(1) + arg(2) /*concise, but never executed." " " */</lang>
add.2.args: say 'Whoa Nelly!! Has the universe run amok?'
/* [↑] dead code, never XEQed*/
add.2.args: return arg(1) + arg(2) /*concise, but never executed.*/</lang>
'''output'''
<pre>