NET/MASTER Network Control Language (NCL) Reference Manual
SUBSTR
Built-in Functions
4–80 106126 Tandem Computers Incorporated
Examples
In the following example, beginning at character position 2 of the string “abc”, the next
two characters “bc” form the substring that is returned:
&A =ABC
&B = 2
&RESULT = SUBSTR(&A,&B)
In the following example, beginning at character position 7 of the string
“abcdefghijklmno”, the rest of the string is returned.
length2
is specified as longer
than the length of the string from character position 7 to the end of the string. By
specifying
length2
, the
pad
and
length
operands are ignored. The resulting
substring is “ghijklmno”:
&A = ABCDEFGHIJKLMNO
&B = 7
&C = 5
&D = #
&E = 20
&RESULT = SUBSTR(&A,&B,&C,&D,&E)
In the following example, beginning at character position 7 of the string “abcdefghi”,
the rest of the string is returned. Because the
length
operand is not specified, the
substring returned is from character position 7 to the end of the string. No padding is
necessary even though a pad character is specified. The resulting substring is “ghi”:
SAY SUBSTR(abcdefghi,7,,#)
In the following example
n
is specified as 25, and is beyond the length of the string
“abcdefghi”. The null string “” is returned, and the pad character is ignored:
SAY SUBSTR(abcdefghi,25,,#)
In the following example, beginning at character position 1 of the string “abcdefg”, ten
characters are returned. Because the requested length of the substring, specified in
length
(10), is larger than the original string, the pad character of a dollar sign ($) is
used to extend the substring to its required length. The resulting substring is
“abcdefg$$$”:
SAY SUBSTR(abcdefg,1,10,$)