$Lstr_Word

From m204wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Return a word from a long string

Note: Most SOUL $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $Lstr_Word is Word (except that Word does not allow a word number argument less than 1, as does $Lstr_Word.) Or, you may find the features of the StringTokenizer to be more helpful.

This function takes a Longstring input and a word number and returns a Longstring containing a single word. A null string is returned if the word count in the input Longstring is less than the word number.

Syntax

%result = $Lstr_Word(longstring, n, delims)

%result is a Longstring that is the nth word in the longstring argument.

longstring is an arbitrary Longstring. This is a required argument.

n is the number of the desired word. The first word in the longstring input is word 1.

delims is a string containing from 1 to 255 characters which are the delimiters for longstring. This is an optional argument, and it defaults to a blank.

Examples

  1. To set %res to "shore":

    %res = $Lstr_Word('She sells sea-shells by the sea shore', 7)

  2. To set %res to "sea":

    %res = $Lstr_Word('She sells sea-shells by the sea shore', 7, '- ')

See also

Products authorizing $Lstr_Word