RestOfString (StringTokenizer function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 11: Line 11:
<td>A string variable to receive the characters that follow the next token. </td></tr>
<td>A string variable to receive the characters that follow the next token. </td></tr>
<tr><th>%tok</th>
<tr><th>%tok</th>
<td>A StringTokenizer object variable.</td></tr>
<td>A <var>StringTokenizer</var> object variable.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>The RestOfString operation does not advance the NextPosition value.
<li>The <var>RestOfString</var> operation does not advance the NextPosition value.
<li>RestOfString depends only on the value of the most recent NextPosition
<li><var>RestOfString</var> depends only on the value of the most recent NextPosition
or [[NextChar (StringTokenizer function)|NextChar]] call; it
or [[NextChar (StringTokenizer function)|NextChar]] call; it
is independent of the values of [[CurrentToken (StringTokenizer function)|CurrentToken]]
is independent of the values of [[CurrentToken (StringTokenizer function)|CurrentToken]]
and [[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]].
and [[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]].
<li>If the value of [[AtEnd (StringTokenizer function)|AtEnd]] is <tt>True</tt>,
<li>If the value of [[AtEnd (StringTokenizer function)|AtEnd]] is <tt>True</tt>,
issuing RestOfString is '''not''' an error but returns a null string.
issuing <var>RestOfString</var> is '''not''' an error but returns a null string.
<li>The [[StartOfString (StringTokenizer function)|StartOfString]] function
<li>The [[StartOfString (StringTokenizer function)|StartOfString]] function
returns the substring of the tokenizer string that precedes the first character of
returns the substring of the tokenizer string that precedes the first character of
Line 28: Line 28:
==Examples==
==Examples==


The following request fragment shows that consecutive RestOfString statements
The following request fragment shows that consecutive <var>RestOfString</var> statements
return the same value so do not advance the NextPosition value, and it shows that
return the same value so do not advance the NextPosition value, and it shows that
RestOfString returns a null string
<var>RestOfString</var> returns a null string
if issued when the position is at the end of the string:
if issued when the position is at the end of the string:
<pre>
<pre>
     %tok:string = 'restOfString example'
     %tok:string = 'restOf<var>String</var> example'
     printText {%tok:nextToken}
     printText {%tok:nextToken}
     printText {%tok:restOfString}
     printText {%tok:restOfString}
Line 43: Line 43:
The result is:
The result is:
<pre>
<pre>
     restOfString
     restOf<var>String</var>
     example
     example
     example
     example

Revision as of 21:47, 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 = 'restOf<var>String</var> example'
    printText {%tok:nextToken}
    printText {%tok:restOfString}
    printText {%tok:restOfString}
    printText {%tok:nextToken}
    printText {%tok:restOfString} \\

The result is:

    restOf<var>String</var>
     example
     example
    example
     \\

See also