RestOfString (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>Non-tokenized substring that follows the next token</b></span>
{{Template:StringTokenizer:RestOfString subtitle}}
[[Category:StringTokenizer methods|RestOfString function]]
<!--DPL?? Category:StringTokenizer methods|RestOfString function: Non-tokenized substring that follows the next token-->
<!--DPL?? Category:System methods|RestOfString (StringTokenizer function): Non-tokenized substring that follows the next token-->
<p>
RestOfString is a member of the [[StringTokenizer class]].
</p>


This method returns the current non-tokenized substring of the tokenizer string.
This method returns the current non-tokenized substring of the tokenizer string.
This substring starts from the position after the next token ([[NextPosition (StringTokenizer property)|NextPosition]]),
This substring starts from the position after the next token ([[NextPosition (StringTokenizer property)|NextPosition]]),
and it includes the remaining characters going forward to the end of the string.
and it includes the remaining characters going forward to the end of the string.
===Syntax===
==Syntax==
  %string = %tok:RestOfString
{{Template:StringTokenizer:RestOfString syntax}}
===Syntax terms===
===Syntax terms===
<dl>
<dl>
Line 20: Line 14:


</dl>
</dl>
===Usage Notes===
==Usage notes==
<ul>
<ul>
<li>The RestOfString operation does not advance the NextPosition value.
<li>The RestOfString operation does not advance the NextPosition value.
Line 33: Line 27:
the current token (this first-character position is returned by CurrentTokenPosition).
the current token (this first-character position is returned by CurrentTokenPosition).
</ul>
</ul>
===Examples===
==Examples==


The following request fragment shows that consecutive RestOfString statements
The following request fragment shows that consecutive RestOfString statements
Line 56: Line 50:
     \\
     \\
</pre>
</pre>
==See also==
{{Template:StringTokenizer:RestOfString footer}}

Revision as of 19:54, 6 February 2011

Non-tokenized substring that follows the next token (StringTokenizer class)


This method returns the current non-tokenized substring of the tokenizer string. This substring starts from the position after the next token (NextPosition), and it includes the remaining characters going forward to the end of the string.

Syntax

%string = stringTokenizer:RestOfString

Syntax terms

%string
A string variable to receive the characters that follow the next token.
%tok
A StringTokenizer object variable.

Usage notes

  • The RestOfString operation does not advance the NextPosition value.
  • RestOfString depends only on the value of the most recent NextPosition or NextChar call; it is independent of the values of CurrentToken and CurrentTokenPosition.
  • If the value of AtEnd is True, issuing RestOfString is not an error but returns a null string.
  • The StartOfString function returns the substring of the tokenizer string that precedes the first character of the current token (this first-character position is returned by CurrentTokenPosition).

Examples

The following request fragment shows that consecutive RestOfString statements return the same value so do not advance the NextPosition value, and it shows that RestOfString returns a null string if issued when the position is at the end of the string:

    %tok:string = 'restOfString example'
    printText {%tok:nextToken}
    printText {%tok:restOfString}
    printText {%tok:restOfString}
    printText {%tok:nextToken}
    printText {%tok:restOfString} \\

The result is:

    restOfString
     example
     example
    example
     \\

See also