REXX interpretation considerations
Workload Automation Programming Language variables are replaced with their actual value immediately before a command is run.
Because Workload Automation Programming Language is written in REXX, some commands exploit the REXX interpreter. As a consequence, when you use REXX functions or expressions you need to ensure that a variable value does not contain blanks because this might modify the way the command is run. Make also sure that mathematical operators, if any, do not cause the variable to resolve to more than 250 characters. Every time you set a variable that contain blanks or mathematical characters, such as +, -, /, * or %, you must include the variable name by double quotation marks.
CONSOLE
DISPLAY
DO WHILE
DO UNTIL
IF-THEN
LOG
WRITE
- When
VARSET =
is used, REXX interpretation is performed. The keyword based variant ofVARSET
does not use REXX interpretation.
IF (“!TAG” = “-JOBNAME”) THEN
DO WHILE RIGHT(“!LINE”,1) <> “1”
@V
function, which returns a variable
value into a REXX expression and automatically returns values between double quotes into the
expression. It also works without variable substitution being active, which allows variables to
be used in expressions that might include the variable prefix for other purposes. For
example:IF (@V(TAG) = “-JOBNAME”) THEN
DO WHILE RIGHT(@V(LINE),1) <> “1”
You can use this function together with variable substitution, to subscript a variable, such as
an object variable, without the need for a separate VARSET VARIABLE
statement.
VARSUB SCAN
VARSET CMD1 = "F WSIC,STATUS"
VARSET CMD2 = "F WSJC,STATUS"
VARSET CMD3 = "F WSKC,STATUS" VARSET CMD4 = "F WSLC,STATUS"
DO X = 1 TO 4
CONSOLE @V(CMD!X)
WAIT 10
END
VARSET CHAR =
SUBSTR(ENVATTR(DD,DSNAME,MYDD,1),2,1)
The only exceptions are the functions whose names begin with the at sign (@), which cannot have anything nested within them, and are resolved prior to the line being executed. The @ functions must be included within double quotes.
To avoid resolution issues, you can use the REXX equivalent of Workload Automation Programming Language variables. Such variables
use the same names but are prefixed with com.VAR.
and do not need the
exclamation mark (!) as prefix. For these variables the REXX rules apply, with the exception that
if they were not defined in an earlier command, they resolve to a zero length string. These
variables are managed like normal REXX variables and are resolved at running time, not
before.
For example, IF (“!TAG” = “-JOBNAME”) THEN
could be replaced with
(com.VAR.TAG = “-JOBNAME”) THEN
This avoids problems with blanks, mathematical characters, and the risk of exceeding the limit of 250 characters.
VARSET
command, as in the following
example:VARSET MYLINE VARIABLE(@MYOBJ-!RX)