Programmer Guide/Command Reference/TOKEN: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
  <var>var</var> := TOKEN [ [[Command_Reference_Options/Silent|/Silent]] ] [ /D=<var>delimiter</var> ] [[Programmer_Guide/Command_Reference_Options/-|/-]] <var>index</var> <var>string<sub>1</sub></var> <var>string<sub>2</sub></var>
  <var>var</var> := TOKEN [ [[Programmer_Guide/Command_Reference_Options/Silent|/Silent]] ] [ /D=<var>delimiter</var> ] [[Programmer_Guide/Command_Reference_Options/-|/-]] <var>index</var> <var>string<sub>1</sub></var> <var>string<sub>2</sub></var>


This command, similar to the <code>[[Programmer Guide/Command Reference/WORD|WORD]]</code> command, tokenises a string using blanks, or the specified delimiter.
This command, similar to the <code>[[Programmer Guide/Command Reference/WORD|WORD]]</code> command, tokenises a string using blanks, or the specified delimiter.
Line 14: Line 14:
:A string to tokenise.
:A string to tokenise.


;<code>[[Command_Reference_Options/Silent|/Silent]]</code>
;<code>[[Programmer_Guide/Command_Reference_Options/Silent|/Silent]]</code>
:If set, the function sets the return code on failure. Otherwise, it sets the return code to 0, even if the parameters are invalid.
:If set, the function sets the return code on failure. Otherwise, it sets the return code to 0, even if the parameters are invalid.



Revision as of 15:22, 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.

index
The zero-based index of the word to return (0 ≤ indexnWords-1).
string1 string2
A string to tokenise.
/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
Set the delimiter using the following format:
/Delimiter=delimiter, e.g. #var := token /D=, /- $#index $#wordlist
The default delimiter is a blank.

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'

Navigation menu

Personal tools