Special variables: Difference between revisions

Content deleted Content added
m →‎{{header|REXX}}: changed some comments in the REXX section header, removed STYLE from the PRE html TAG, aligned some statements.
Line 1,302:
The REXX language has three special variables:
 
:::*   '''RC'''             [the '''r'''eturn '''c'''ode from commands issued to the host]
:::*   '''RESULT'''     [the result RETURNed from a subroutine or function]
:::*   '''SIGL'''         [the source line number that did the transfer of control]
 
Each of the above may be used as a regular REXX variable,;   they aren't reserved keywords or reserved variable names.
<br>Because REXX may define (or re-define) any of these variables during execution of the REXX program, it isn'tits recommended that they be not be used as regular REXX variables.
 
Initially, the above three special variables aren't defined &nbsp; (until the appropriate action for their use has been performed).
Line 1,314:
: If no subroutines have been invoked, then the &nbsp; '''RESULT''' &nbsp; special variable isn't defined.
: If no SIGNAL or CALL (or subroutine invocation) has been used, then the &nbsp; '''SIGL''' &nbsp; special variable isn't defined.
:::: (This excludes the use of:
:: (This excludes the use of &nbsp; '''SIGNAL ON ααα''' &nbsp; and/or &nbsp; '''SIGNAL OFF ααα''' &nbsp; instructions which don't actually transfer control.)
:::::::* &nbsp; '''SIGNAL ON &nbsp; ααα'''
:::::::* &nbsp; '''SIGNAL OFF ααα'''
:::: which don't actually transfer control.)
 
In each case, the three special variable names &nbsp; ('''RC''', &nbsp; '''RESULT''', &nbsp; and &nbsp; '''SIGL''') &nbsp; may be in lower/upper/mixed case.
<br><br>The scope of the special variables is &nbsp; LOCAL.
<lang rexx>/*REXX program to demonstratedemonstrates REXX special variables: RC, RESULT, SIGL. */
/*line two. */
/*line three.*/ say copies('=',7579)
rc=1/3 /*line four. */
signal youWho /*line five. */
myLoo='this got skipped' /*line six. */
youwho: /*line seven.*/
sep=copies('─', 9) /*line eight.*/
say 'SIGL=' sigl
say 'REXXsep source statement' SIGL '=' sourceline(sigl) /*line nine. */
say sep 'REXX source statement' SIGL '=' sourceline(sigl)
say copies('=',7579)
g=44
call someFunchalve g
say sep 'rc=' rc
say sep 'result=' result
say copies('=',7579)
h=66
hh=someFunchalve(h)
say sep 'rc=' rc
say sep 'result=' result
say sep 'hh=' hh
say copies('=',7579)
'DIR C:\ /ad /b' | find /i /v*display "Volumethe "directories '(Bare).*/
say sep 'rc=' rc
say sep 'result=' result
say copies('=',7579)
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────HALVE subroutine────────────────────*/
/*───────────────────────────────────someFunc subroutine.───────────────*/
someFunchalve: procedure;return arg(1) / 2 parse arg x; return x/2*a simple halving function. */</lang>
'''output'''
<pre>
<pre style="overflow:scroll">
═══════════════════════════════════════════════════════════════════════════════
===========================================================================
───────── SIGL= 5
SIGL= 5
───────── REXX source statement 5 = signal youWho /*line five. */
═══════════════════════════════════════════════════════════════════════════════
===========================================================================
───────── rc= 0.333333333
───────── result= 22
═══════════════════════════════════════════════════════════════════════════════
===========================================================================
───────── rc= 0.333333333
───────── result= 22
───────── hh= 33
hh= 33
═══════════════════════════════════════════════════════════════════════════════
===========================================================================
Documents and Settings
 
Program Files
Directory of C:\
Recycled
 
System Volume Information
04/26/2012 01:51 <DIR> bigFacts
TEMP
12/16/2005 19:54 <DIR> Documents and Settings
WINDOWS
04/26/2012 01:51 <DIR> gon
───────── rc= 0
12/16/2005 20:16 <DIR> Program Files
───────── result= 22
04/14/2010 19:58 <DIR> Recycled
═══════════════════════════════════════════════════════════════════════════════
12/16/2005 19:42 <DIR> WINDOWS
0 File(s) 0 bytes
7 Dir(s) 4,697,964,544 bytes free
rc= 0
result= 22
===========================================================================
</pre>