Programmer Guide/Command Reference/TOKEN: Difference between revisions
From STX Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
;<var>index</var> | ;<var>index</var> | ||
:The zero-based index of the token to return (0 ≤ <var>index</var> ≤ <var>nWords</var>-1). | :The zero-based index of the token to return (0 ≤ <var>index</var> ≤ <var>nWords</var>-1), <var>nWords</var> meaning the number tokens available in the <var>string</var> argument. | ||
;<var>string</var>… | ;<var>string</var>… |
Revision as of 15:09, 2 May 2014
var := TOKEN [ /Silent ] [ /D=delimiter ] /- index string…
This command, similar to the WORD
command, tokenises a string into words separated by a delimiter specified with the /delimiter
option.
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, nTokens indicating the number of available tokens in the string argument.
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.
- index
- The zero-based index of the token to return (0 ≤ index ≤ nWords-1), nWords meaning the number tokens available in the string argument.
- string…
- A string to tokenise. If you supply more than one string, they will still be considered one string, following STx rules for argument concatenation.
/Silent
- If set, the function sets the return code on failure. Otherwise, it sets the return code to 0, even if the parameters are invalid.
/Delimiter=delimiter
- Set the delimiter character. The default delimiter is a blank character.
Example
#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'