PeekChar (StringTokenizer function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 5: Line 5:
The tokenizing position is the value returned by [[NextPosition (StringTokenizer property)|NextPosition]].
The tokenizing position is the value returned by [[NextPosition (StringTokenizer property)|NextPosition]].


After returning the character value, PeekChar does not advance the
After returning the character value, <var>PeekChar</var> does not advance the
tokenizing position,
tokenizing position,
which remains what it was when PeekChar was called.
which remains what it was when <var>PeekChar</var> was called.
==Syntax==
==Syntax==
{{Template:StringTokenizer:PeekChar syntax}}
{{Template:StringTokenizer:PeekChar syntax}}
Line 15: Line 15:
<td>A string variable to receive the value of the character at the tokenizing position. </td></tr>
<td>A string variable to receive the value of the character at the tokenizing position. </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>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 PeekChar is invalid and cancels the request.
issuing <var>PeekChar</var> is invalid and cancels the request.
<li>The [[NextChar (StringTokenizer function)|NextChar]] function also returns the value of the
<li>The [[NextChar (StringTokenizer function)|NextChar]] function also returns the value of the
next character, but it advances the tokenizing position past the next character.
next character, but it advances the tokenizing position past the next character.
Line 28: Line 28:
The following sequence of printText statements display,
The following sequence of printText statements display,
respectively, <tt>A</tt>, <tt>A</tt>, <tt>A</tt>, and <tt>n</tt>,
respectively, <tt>A</tt>, <tt>A</tt>, <tt>A</tt>, and <tt>n</tt>,
showing that the tokenizing position does not move after PeekChar completes,
showing that the tokenizing position does not move after <var>PeekChar</var> completes,
PeekChar and NextChar return the same value, and NextChar does
<var>PeekChar</var> and NextChar return the same value, and NextChar does
advance the tokenizing position:
advance the tokenizing position:
<pre>
<pre>

Revision as of 21:47, 6 February 2011

Value of character at current tokenizing position, do not advance (StringTokenizer class)


This method returns the value of the character that is at the tokenizing position. The tokenizing position is the value returned by NextPosition.

After returning the character value, PeekChar does not advance the tokenizing position, which remains what it was when PeekChar was called.

Syntax

%string = stringTokenizer:PeekChar

Syntax terms

%string A string variable to receive the value of the character at the tokenizing position.
%tok A StringTokenizer object variable.

Usage notes

  • If the value of AtEnd is True, issuing PeekChar is invalid and cancels the request.
  • The NextChar function also returns the value of the next character, but it advances the tokenizing position past the next character.

Examples

The following sequence of printText statements display, respectively, A, A, A, and n, showing that the tokenizing position does not move after PeekChar completes, PeekChar and NextChar return the same value, and NextChar does advance the tokenizing position:

    %tok:string = 'An example of peekChar'
    printText {%tok:peekChar}
    printText {%tok:peekChar}
    printText {%tok:nextChar}
    printText {%tok:nextChar}

See also