Introspection: Difference between revisions
Content added Content deleted
m (→{{PowerBASIC}}: spelling error) |
m (→{{header|REXX}}: added whitespace, changed some comments in the section headers.) |
||
Line 1,707: | Line 1,707: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Test to see if the version is at least version 4. |
Test to see if the version is at least version 4. |
||
<lang rexx> /*output from parse version (almost all REXX versions) */ |
<lang rexx> /*output from parse version (almost all REXX versions) */ |
||
/* theREXXinterpreterName level mm Mon yyyy */ |
/* theREXXinterpreterName level mm Mon yyyy */ |
||
parse version . level . |
parse version . level . |
||
if level<4 then exit</lang> |
if level<4 then exit</lang> |
||
Test to see if the version is at least version 4, another example. |
Test to see if the version is at least version 4, another example. |
||
<lang rexx>parse version x 1 whatLang level |
<lang rexx>parse version x 1 whatLang level dd mon yyyy . |
||
if level<4 then do |
if level<4 then do |
||
say |
say |
||
say 'version' level "is too old!" |
say 'version' level "is too old!" |
||
say x /*this displays everything.*/ |
say x /*this displays everything.*/ |
||
exit /*or maybe: EXIT 13 */ |
exit /*or maybe: EXIT 13 */ |
||
end</lang> |
end</lang> |
||
Test to see if the REXX variable "bloop" exists, version 1. |
Test to see if the REXX variable "bloop" exists, version 1. |
||
<lang rexx>if symbol('bloop')=='VAR' then say 'the "bloop" variable exists.'</lang> |
<lang rexx>if symbol('bloop')=='VAR' then say 'the "bloop" variable exists.'</lang> |
||
Test to see if the REXX variable "bloop" exists, version 2. |
Test to see if the REXX variable "bloop" exists, version 2. |
||
<lang rexx>if symbol('bloop')=='VAR' then say 'the "bloop" variable exists.' |
<lang rexx>if symbol('bloop')=='VAR' then say 'the "bloop" variable exists.' |
||
else say 'the "bloop" variable doesn''t exist.'</lang> |
else say 'the "bloop" variable doesn''t exist.'</lang> |
||
Programming note: note the use of the double apostrophe (<big>''' ' ' '''</big>) which is within a quoted string (with apostrophes) [in the above and below REXX programming examples]. |
Programming note: note the use of the double apostrophe (<big>''' ' ' '''</big>) which is within a quoted string (with apostrophes) [in the above and below REXX programming examples]. |
||
<br>Another test to see if the REXX variable "bloop" exists. |
<br>Another test to see if the REXX variable "bloop" exists. |
||
<lang rexx>bloop=47 |
<lang rexx>bloop=47 |
||
if symbol('bloop')=='VAR' then say 'the "bloop" variable exists.' |
if symbol('bloop')=='VAR' then say 'the "bloop" variable exists.' |
||
else say 'the "bloop" variable doesn''t exist.'</lang> |
else say 'the "bloop" variable doesn''t exist.'</lang> |
||
In REXX, the ABS function is a built-in function (BIF). |
In REXX, the ABS function is a built-in function (BIF). |
||
<lang rexx>bloop=47 |
<lang rexx>bloop=47 |
||
g=abs(bloop)</lang> |
g=abs(bloop)</lang> |
||
However, most REXX |
However, most REXX interpreters will allow this type of test: |
||
<lang rexx>if testxyz() then say 'function XYZ not found.' |
<lang rexx>if testxyz() then say 'function XYZ not found.' |
||
else say 'function XYZ was found.' |
else say 'function XYZ was found.' |
||
exit |
exit |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
testxyz: signal on syntax |
testxyz: signal on syntax |
||
call XYZ |
call XYZ |
||
return 0 |
return 0 |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
syntax: return 1</lang> |
syntax: return 1</lang> |
||
=={{header|Ruby}}== |
=={{header|Ruby}}== |