Reflection/Get source: Difference between revisions

→‎{{header|REXX}}: added the REXX language.
(added Tcl)
(→‎{{header|REXX}}: added the REXX language.)
Line 150:
# "/usr/local/lib/python3.5/os.pyc"
</lang>
 
=={{header|REXX}}==
This REXX version was modeled after the &nbsp; '''zkl''' &nbsp; example, but in addition, it also displays the source.
<lang rexx>/*REXX program gets the source function (source code) and */
/*───────────────────────── displays the number of lines. */
#=sourceline()
do j=1 for sourceline()
say 'line' right(j, length(#) ) '──►' ,
strip( sourceline(j), 'T')
end /*j*/
say
parse source x y sID
say 'The name of the source file (program) is: ' sID
say 'The number of lines in the source program: ' #
/*stick a fork in it, we're all done.*/</lang>
{{out|output|:}}
<pre>
line 1 ──► /*REXX program gets the source function (source code) and */
line 2 ──► /*───────────────────────── displays the number of lines. */
line 3 ──► #=sourceline()
line 4 ──► do j=1 for sourceline()
line 5 ──► say 'line' right(j, length(#) ) '──►' ,
line 6 ──► strip( sourceline(j), 'T')
line 7 ──► end /*j*/
line 8 ──► say
line 9 ──► parse source x y sID
line 10 ──► say 'The name of the source file (program) is: ' sID
line 11 ──► say 'The number of lines in the source program: ' #
line 12 ──► /*stick a fork in it, we're all done.*/
 
The name of the source file (program) is: c:\reflecti.rex
The number of lines in the source program: 12
</pre>
 
=={{header|Ruby}}==