PeekPreviousChar (StringTokenizer function): Difference between revisions
m (→Usage notes) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{Template:StringTokenizer:PeekPreviousChar subtitle}} | {{Template:StringTokenizer:PeekPreviousChar subtitle}} | ||
This | This method returns the value of the character that precedes the character that is at the tokenizing position. | ||
The tokenizing position is the value returned by [[NextPosition (StringTokenizer property)|NextPosition]]. | |||
After returning the character value, <var>PeekPreviousChar</var> does not change the | |||
tokenizing position, which remains what it was when <var>PeekPreviousChar</var> was called. | |||
==Syntax== | ==Syntax== | ||
{{Template:StringTokenizer:PeekPreviousChar syntax}} | {{Template:StringTokenizer:PeekPreviousChar syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%string</th><td>string</td></tr> | <tr><th>%string</th> | ||
<td>A string variable to receive the value of the character that precedes the character at the tokenizing position. </td></tr> | |||
<tr><th>stringTokenizer</th> | <tr><th>stringTokenizer</th> | ||
<td>StringTokenizer object</td></tr> | <td>A <var>StringTokenizer</var> object expression.</td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>If you | <li>If you are not using separators, <var>PeekPreviousChar</var> always returns the | ||
last character of the last returned token. | last character of the last returned token. | ||
<li>The [[PreviousChar (StringTokenizer function)|PreviousChar]] function also returns the value of the character that precedes the character that is at the tokenizing position, but it steps the tokenizing position back to the preceding character. | |||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
The following sequence of <var>[[Targeted Text statements|PrintText]]</var> statements display, | |||
respectively, <code>Example</code>, <code>e</code>, <code>l</code>, <code>p</code>, and <code>p</code>, | |||
showing that the tokenizing position moves after <var>PreviousChar</var> completes | |||
but not after <var>PeekPreviousChar</var> completes: | |||
<p class="code">%tok = new | |||
%tok:string = 'Example of peekPreviousChar' | |||
PrintText {~} is {%tok:nextToken} | |||
PrintText {~} is {%tok:previousChar} | |||
PrintText {~} is {%tok:previousChar} | |||
PrintText {~} is {%tok:peekPreviousChar} | |||
PrintText {~} is {%tok:peekPreviousChar} | |||
</p> | |||
==See also== | ==See also== | ||
{{Template:StringTokenizer:PeekPreviousChar footer}} | {{Template:StringTokenizer:PeekPreviousChar footer}} |
Revision as of 20:51, 5 July 2012
Value of previous character (StringTokenizer class)
[Introduced in Sirius Mods 7.8]
This method returns the value of the character that precedes the character that is at the tokenizing position.
The tokenizing position is the value returned by NextPosition.
After returning the character value, PeekPreviousChar does not change the tokenizing position, which remains what it was when PeekPreviousChar was called.
Syntax
%string = stringTokenizer:PeekPreviousChar
Syntax terms
%string | A string variable to receive the value of the character that precedes the character at the tokenizing position. |
---|---|
stringTokenizer | A StringTokenizer object expression. |
Usage notes
- If you are not using separators, PeekPreviousChar always returns the last character of the last returned token.
- The PreviousChar function also returns the value of the character that precedes the character that is at the tokenizing position, but it steps the tokenizing position back to the preceding character.
Examples
The following sequence of PrintText statements display,
respectively, Example
, e
, l
, p
, and p
,
showing that the tokenizing position moves after PreviousChar completes
but not after PeekPreviousChar completes:
%tok = new %tok:string = 'Example of peekPreviousChar' PrintText {~} is {%tok:nextToken} PrintText {~} is {%tok:previousChar} PrintText {~} is {%tok:previousChar} PrintText {~} is {%tok:peekPreviousChar} PrintText {~} is {%tok:peekPreviousChar}