NET/MASTER Network Control Language (NCL) Reference Manual
SUBWORD
Built-in Functions
106126 Tandem Computers Incorporated 4–81
SUBWORD The SUBWORD built-in function extracts a substring from a string, starting from a
specified word in the string. It deletes trailing spaces after the last word in the output
string. All spaces between words are preserved.
SUBWORD(
string
,
n
[,
length
] )
string
specifies the string on which the extraction is to be performed.
n
specifies the word position at which the extraction is to begin.
n
must be a
positive whole number. If
n
specifies a word position beyond the end of the
string, a null string is returned.
length
specifies the number of words to be returned. If
length
is omitted, the entire
source string (from word position
n
) is returned. Trailing spaces after the last
word in
string
are not returned. This operand must be a nonnegative whole
number. If
length
is not specified, the output string consists of all words from
word position
n
to the end of the supplied string.
Consideration
See also DELWORD and WORDPOS. The DELWORD built-in function deletes a
specified number of words from a string. The WORDPOS built-in function returns the
first position of a string of words within another string.
Examples
In the following example, beginning from the fourth word of the string “1 2 3 4 5 ”,
the rest of the string is extracted. The resulting substring is “4 5”. The trailing spaces
are omitted, but the spaces between words are preserved:
SAY SUBWORD(1 2 3 4 5 ,4)
In the following example, beginning from the second word of the string
“ abc def ghi jkl”, two words are extracted. The resulting substring is “def ghi”:
&A = ABC DEF GHI JKL
&RESULT = SUBWORD(&A,2,2)