CurrentToken (StringTokenizer function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
<span style="font-size:120%; color:black"><b>String value of current token</b></span>
{{Template:StringTokenizer:CurrentToken subtitle}}
[[Category:StringTokenizer methods|CurrentToken function]]
<!--DPL?? Category:StringTokenizer methods|CurrentToken function: String value of current token-->
<!--DPL?? Category:System methods|CurrentToken (StringTokenizer function): String value of current token-->
<p>
CurrentToken is a member of the [[StringTokenizer class]].
</p>


This method returns the string value of the current token.
This method returns the string value of the current token.
Line 13: Line 7:
these calls has been made.
these calls has been made.


As described in &ldquo;Usage Notes,&rdquo; below, you can also update the current
As described in "Usage Notes," below, you can also update the current
token by explicitly setting the value of [[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]].
token by explicitly setting the value of [[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]].
===Syntax===
==Syntax==
  %string = %tok:CurrentToken
{{Template:StringTokenizer:CurrentToken syntax}}
===Syntax terms===
===Syntax terms===
<dl>
<dl>
Line 25: Line 19:


</dl>
</dl>
===Usage Notes===
==Usage notes==
<ul>
<ul>
<li>The [[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]] property is the position of
<li>The [[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]] property is the position of
Line 35: Line 29:
or [[NextPosition (StringTokenizer property)|NextPosition]] call.
or [[NextPosition (StringTokenizer property)|NextPosition]] call.
</ul>
</ul>
===Examples===
==Examples==


The following request fragment shows how the successful execution
The following request fragment shows how the successful execution
Line 69: Line 63:
     %tok:currentTokenPosition is 15
     %tok:currentTokenPosition is 15
</pre>
</pre>
==See also==
{{Template:StringTokenizer:CurrentToken footer}}

Revision as of 19:54, 6 February 2011

String value of current token (StringTokenizer class)


This method returns the string value of the current token. The current token is typically the most recent token returned by NextToken or FindToken. CurrentToken is invalid and cancels the request until one of these calls has been made.

As described in "Usage Notes," below, you can also update the current token by explicitly setting the value of CurrentTokenPosition.

Syntax

%string = stringTokenizer:CurrentToken Throws MismatchedQuote, OutOfBounds

Syntax terms

%string
A string variable to receive the value of the current token.
%tok
A StringTokenizer object variable.

Usage notes

  • The CurrentTokenPosition property is the position of the initial character in the current token. Conversely, the current token always starts at the position given by CurrentTokenPosition. If you reset CurrentTokenPosition, you automatically modify the current token substring — but this has no effect on a subsequent NextToken or NextPosition call.

Examples

The following request fragment shows how the successful execution of NextToken advances the current token and current token position. For an example where the CurrentToken value follows an explicit setting of CurrentTokenPosition, see ?? refid=tkxmpcp..

    %tok = new
    %tok:string = 'current token example'
    PrintText {~} is {%tok:nextToken}
    PrintText {~} is {%tok:currentToken}
    PrintText {~} is {%tok:currentTokenPosition}

    PrintText {~} is {%tok:nextToken}
    PrintText {~} is {%tok:currentTokenPosition}
    PrintText {~} is {%tok:currentToken}

    PrintText {~} is {%tok:nextToken}
    PrintText {~} is {%tok:currentToken}
    PrintText {~} is {%tok:currentTokenPosition}

The result is:

    %tok:nextToken is current
    %tok:currentToken is current
    %tok:currentTokenPosition is 1
    %tok:nextToken is token
    %tok:currentTokenPosition is 9
    %tok:currentToken is token
    %tok:nextToken is example
    %tok:currentToken is example
    %tok:currentTokenPosition is 15

See also