NET/MASTER Network Control Language (NCL) Reference Manual

VARSUB
Built-in Functions
106126 Tandem Computers Incorporated 4–101
VARSUB The VARSUB built-in function performs variable substitution on a string and returns
the substituted string. It scans
string
for variables denoted by
subchar
and
replaces the variable with its contents. The process is repeated until
number
is
reached or there are no more variables to substitute. The built-in function returns a
string consisting of either text or text and unsubstituted variable names (if scanning is
incomplete).
VARSUB(
string
[ [ ,
number
] ,
subchar
] )
string
specifies the string that requires variable substitution.
number
specifies the number of times the string is to be scanned for substitution. The
default is 1. You can specify a number from 1 through 16. The string is scanned,
at most, the number of times necessary to substitute all the variables present; if
this is less than
number
, the scanning stops. See the fourth example given later.
subchar
specifies the character that designates a variable (the variable designator). This
allows you to alter the variable designator to a value other than the default value
of the ampersand (&). By altering the variable designator you prevent NCL from
substituting variables with their values before parsing the string, which would
lead to syntax errors.
You can specify one of the following characters:
~ ` ! % ^ & - + = [ ] | \ : ; " ' < > , /
Considerations
The following system variables are set if a variable parsed by VARSUB results in a
run-time error:
&SYS.ERROR.COND contains the name of the error condition.
&SYS.ERROR.VALUE contains the string being parsed when the error
occurred. If more than one pass was requested, this is a string already
substituted by VARSUB and not the original string.
&SYS.ERROR.VALUE2 contains “Curr Pass# n” where n is the current pass
number when the error occurred.
&SYS.ERROR.NAME contains the variable name, less the initial variable
designator, of the variable that caused the error.
Leading or trailing blanks are returned by VARSUB if they are present in the
original string passed to VARSUB.