Owning Palette: Additional String VIs and Functions
Requires: Base Development System
Scans input string starting at offset for tokens and outputs each segment as a token string.

Add to the block diagram |
Find on the palette |
Tokens are text segments that typically represent individual keywords, numeric values, or operators found when parsing a configuration file or other text-based data format. You can specify tokens with the data you pass into the function through the delimiters and operators inputs. For example, because the space character is a delimiter by default, each word of This is a string is a token, and you can parse the sentence into its component words.
Use this function in a While Loop that processes one section of string at a time until token index returns –2 (indicating end of string). You can pass offset past token through a shift register into offset, so that each scan starts where the preceding scan ended.
By default, the function identifies and returns a token when it encounters a space, tab, carriage return, or linefeed. You can parse a string using these or any other delimiters you choose or you can define operators.
For example, suppose you wire the following values to the function.
| Input | Value |
|---|---|
| input string | This is a testLabVIEWstring |
| offset | 0 (default) |
| operators | [NI,asdf,LabVIEW] |
| delimiters | \s,\t,\r,\n (default) |
If you place the function in a While Loop, the function returns the following values.
| string out | This is a testLabVIEWstring |
| offset past token | 5 |
| token string | This |
| token index | –1 (not an operator) |
| string out | This is a testLabVIEWstring |
| offset past token | 8 |
| token string | is |
| token index | –1 (not an operator) |
| string out | This is a testLabVIEWstring |
| offset past token | 10 |
| token string | a |
| token index | –1 (not an operator) |
| string out | This is a testLabVIEWstring |
| offset past token | 14 |
| token string | test |
| token index | –1 (not an operator) |
| string out | This is a testLabVIEWstring |
| offset past token | 21 |
| token string | LabVIEW |
| token index | 2 (second item in operators) |
| string out | This is a testLabVIEWstring |
| offset past token | –1 (no more tokens present) |
| token string | string |
| token index | –1 (not an operator) |
| string out | This is a testLabVIEWstring |
| offset past token | –1 (no more tokens present) |
| token string | (end of string) |
| token index | –2 (end of string) |