Words (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 41: Line 41:
<ul>
<ul>
<li>[[List of StringTokenizer methods]]
<li>[[List of StringTokenizer methods]]
<li><var>[[Word (String function)|Word]]</var> - Select word from list of words
<li><var>[[WordCount (String function)|WordCount]]</var> - Count words in list
<li><var>[[WordNumberIn and WordNumberOf (String functions)|WordNumberIn and WordNumberOf]]</var> - Word number of "needle" word within "haystack" list of words
<li><var>Words</var> is the OO version of <var>$Lstr_SubWord</var>.
<li><var>Words</var> is the OO version of <var>$Lstr_SubWord</var>.
</ul>
</ul>
{{Template:String:Words footer}}
{{Template:String:Words footer}}

Revision as of 19:11, 27 April 2011

Sublist of 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

%outString = string:Words( start, [count], [Spaces= string])

Syntax terms

%outString Words returns the substring of the string method object which starts at word number start and continues for up to as many words as count.
string The method object string, from which the substring is extracted.
start The number of the word in string that is the start of the extracted substring; must be greater than or equal to 1 (1 designates the first word). If start is greater than the number of words in string, the null string is returned.
count The number of words in the substring to extract. This is an optional argument; the default is to extract the rest of string starting at word number start. If count is greater than the number of words remaining in string starting with word number start, the remainder of the string starting at word number start is returned. This argument must be non-negative; if zero, the null string is returned.
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 {~='aa bb cc':Words(1, 2)}. PrintText {~='aa bb cc':Words(4, 1)}. PrintText {~='aa bb cc':Words(3, 2)}. PrintText {~='aa bb cc':Words(2, 0)}.

produces the following result:

'aa bb cc':Words(2)=bb cc. 'aa bb cc':Words(1, 2)=aa bb. 'aa bb cc':Words(4, 1)=. 'aa bb cc':Words(3, 2)=cc. 'aa bb cc':Words(2, 0)=.

See also