NET/MASTER Network Control Language (NCL) Reference Manual

SUBSTR
Built-in Functions
106126 Tandem Computers Incorporated 4–79
SUBSTR The SUBSTR built-in function extracts a substring from a string, starting from a
specified position within the string. Starting from the specified character, a portion or
the remainder of the string is returned.
SUBSTR(
string
,
n
[, [
length
] [, [
pad
] [,
length2
] ] ] )
string
specifies the string on which the extraction is to be performed.
n
specifies the starting position for the extraction.
n
must be a positive whole
number. If
n
specifies a position beyond the end of
string
, a null string is
returned. If
n
specifies the position of the last character of
string
, that character
is returned.
length
specifies the length of the substring to be returned.
length
must be a
nonnegative whole number. If
length
is not specified, the string returned is from
character position
n
to the end of the string.
pad
specifies the character to be used to pad the string. If specified, this operand must
be only one character in length. The default pad character is a space. If
length
is
not specified, the pad character is ignored.
length2
specifies the length of the substring to be returned. With this option, NCL
interprets
length
differently when it is also used. If
length2
is specified, the
values of
length
and
pad
are overridden. If
length2
is longer than the length
from
n
to the end of the string, the string is returned, with no padding, from
character position
n
to its end. If the string is longer than
length2
, only the
string from
n
to the length of
length2
is returned. See the examples for a
demonstration of how this built-in function works.
Consideration
See also LEFT and RIGHT. The LEFT built-in function returns the leftmost characters
of a string. The RIGHT built-in function returns the rightmost characters of a string.