Word (String function)

From m204wiki
Revision as of 15:46, 27 April 2011 by 198.242.244.36 (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Select word from list of words (String class)

[Introduced in Sirius Mods 7.9]


Note that processing a string of words may be better accomplished with the StringTokenizer class.

Syntax

%selectedWord = string:Word( number, [Spaces= string])

Syntax terms

%selectedWordWord returns the word selected by number within the string method object.
string The list of words, from which the result word is selected.
number The number of the word to select from the string method object. The first word is word number 1. The value of this argument must be greater than or equal to 1.
Spaces A set of "whitespace" characters, that is, characters that separate words. The default is the blank character. If the null string is provided, the blank character is used as the whitespace character.

Usage notes

Examples

The following fragment:

PrintText {~='Dasher**** Dancer**** Prancer****':Word(2)}. PrintText {~='Dasher**** Dancer**** Prancer****':Word(2, Spaces=' *)')}. PrintText {~='One more time':Word(4))}.

produces the following result:

'Dasher**** Dancer**** Prancer****':Word(2)=Dancer****. 'Dasher**** Dancer**** Prancer****':Word(2, Spaces=' *)')=Dancer. 'One more time':Word(4))=.

See also

  • List of StringTokenizer methods
  • Word is the OO version of $Lstr_Word, although there is one difference: $Lstr_Word allows a word number argument which is less than 1 (and treats it the same as if 1 were specified). As mentioned above, Word does not allow a word number argument which is less than 1.