Difference between revisions of "Programmer Guide/Command Reference/TOKEN"

From STX Wiki
Jump to navigation Jump to search
Line 11: Line 11:
:The zero-based index of the word to return (0 &le; <var>index</var> &le; <var>nWords</var>-1).
:The zero-based index of the word to return (0 &le; <var>index</var> &le; <var>nWords</var>-1).
;<var>string<sub>1</sub></var> <var>string<var>2</var></var>
;<var>string<sub>1</sub></var> <var>string<sub>2</sub></var>
:A string to tokenise.
:A string to tokenise.

Revision as of 15:21, 2 May 2014

var := TOKEN [ /Silent ] [ /D=delimiter ] /- index string1 string2

This command, similar to the WORD command, tokenises a string using blanks, or the specified delimiter.

The command returns the respective token or an empty string if index is not a number or if it is outside the range 0…nTokens-1

When using TOKEN, do not forget to use the /- option before the first argument (and after any other options). Without the /- option, any argument starting with a slash will be mistaken for an option.

The zero-based index of the word to return (0 ≤ indexnWords-1).
string1 string2
A string to tokenise.
If set, the function sets the return code on failure. Otherwise, it sets the return code to 0, even if the parameters are invalid.
Set the delimiter using the following format:
/Delimiter=delimiter, e.g. #var := token /D=, /- $#index $#wordlist
The default delimiter is a blank.


#str := set 'to be, or not to be, that is the question'
#var := token /D=, /- 1 $#str
um The second comma separated value in the string "$#str" is "$#var"
// will return ' or not to be'