NET/MASTER Network Control Language (NCL) Reference Manual
VARSUB
Built-in Functions
4–102 106126 Tandem Computers Incorporated
Examples
In the following example, the string requiring variable substitution, “ABC &A XYZ”, is
scanned once. The output string is “ABC 123 XYZ”:
&A = "123"
&result = VARSUB( "ABC &a XYZ" )
SAY "Result is "&result
In the following example, the string requiring variable substitution, “ABC &A XYZ”, is
scanned twice. During the first scan, &A is replaced by “&B”; the result is
“ABC &B XYZ”. During the second scan, &B is replaced by “999”; the output string is
“ABC 999 XYZ”:
&A = "&B"
&B = "999"
&result = VARSUB( "ABC &a XYZ", 2 )
In the following example, the tilde is used as the variable designator and the string
requiring variable substitution, “ABC ~A XYZ”, is scanned three times. During the
first scan, ~A is replaced by “~B”; the result is “ABC ~B XYZ”. During the second
scan, ~B is replaced by “~C”; the result is “ABC ~C XYZ”. During the third scan, ~C is
replaced by “999”; the output string is “ABC 999 XYZ”:
&A = "~B"
&B = "~C"
&C = "999"
&result = VARSUB( "ABC ~A XYZ", 3, "~" )
In the following example, the string requiring variable substitution,
“ABC &A &B &C XYZ”, is scanned a maximum of 16 times (specified by
n
equal to
16). During the first scan, &A is replaced by “&B”, &B is replaced by “&C”, and &C is
replaced by “999”; the result is “ABC &B &C 999 XYZ”. During the second scan, &B is
replaced by “&C”, and &C is replaced by “999”; the result is “ABC &C 999 999 XYZ”.
During the third scan, &C is replaced by “999”; the output string is
“ABC 999 999 999 XYZ”. This is the last scan, though
n
is specified as 16, because
there are no more variables to substitute:
&A = "&B"
&B = "&C”
&C = “999”
&result = VARSUB( "ABC &A &B &C XYZ", 16 )