CurrentTokenPosition (StringTokenizer property): Difference between revisions
m (1 revision) |
mNo edit summary |
||
Line 4: | Line 4: | ||
the current token. | the current token. | ||
If you change the current token (by invoking <var>NextToken</var>, <var>FindToken</var>, or <var>SkipTokens</var>), | If you change the current token (by invoking <var>[[NextToken (StringTokenizer function)|NextToken]]</var>, <var>[[FindToken (StringTokenizer function)|FindToken]]</var>, or <var>[[SkipTokens (StringTokenizer function)|SkipTokens]]</var>), | ||
<var>CurrentTokenPosition</var> is updated with a new value. | <var>CurrentTokenPosition</var> is updated with a new value. | ||
If you explicitly set <var>CurrentTokenPosition</var>, the value returned by | If you explicitly set <var>CurrentTokenPosition</var>, the value returned by | ||
[[CurrentToken (StringTokenizer function)|CurrentToken]] is adjusted accordingly. | <var>[[CurrentToken (StringTokenizer function)|CurrentToken]]</var> is adjusted accordingly. | ||
==Syntax== | ==Syntax== |
Revision as of 21:43, 5 July 2012
Position of first character in the current token (StringTokenizer class)
This readWrite property returns or sets the position of the first character in
the current token.
If you change the current token (by invoking NextToken, FindToken, or SkipTokens), CurrentTokenPosition is updated with a new value. If you explicitly set CurrentTokenPosition, the value returned by CurrentToken is adjusted accordingly.
Syntax
%currentNumber = stringTokenizer:CurrentTokenPosition stringTokenizer:CurrentTokenPosition = newNumber
Syntax terms
%pos | A numeric variable to set or contain the returned value of the current token's first character. |
---|---|
%tok | A StringTokenizer object expression. |
Usage notes
- Issuing CurrentTokenPosition for a new StringTokenizer object is invalid and cancels the request until a NextToken or FindToken call establishes an initial token.
- The NextPosition property returns the position of
the character from which the tokenizer starts parsing for the next token.
The NextPosition and CurrentTokenPosition values value are entirely independent of each other. Both properties can be set to arbitrary locations in the tokenization string. However, if these properties are never explicitly set, NextPosition will always be at least one greater than the position of the last character in the CurrentToken.
Examples
In the following request fragment, the string's first token is selected and immediately becomes the current token with current token position 1. The current token position is then explicitly moved, so the subsequent current token starts at that new position. The subsequent NextToken call, however, ignores the current token position and selects a token based on the position established by the previous NextToken call:
%tok = new(spaces=',') %tok:string = 'start,one,two,three,end' printText {~} is {%tok:nextToken} printText {~} is {%tok:currentToken} printText {~} is {%tok:currentTokenPosition} %tok:currentTokenPosition = 15 printText {~} is {%tok:currentTokenPosition} printText {~} is {%tok:currentToken} printText {~} is {%tok:nextToken}
The result is:
%tok:nextToken is start %tok:currentToken is start %tok:currentTokenPosition is 1 %tok:currentTokenPosition is 15 %tok:currentToken is three %tok:nextToken is one