RestOfString (StringTokenizer function): Difference between revisions
m (1 revision) |
m (→Examples) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
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 (<var>[[NextPosition (StringTokenizer property)|NextPosition]]</var>), 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== | ||
{{Template:StringTokenizer:RestOfString syntax}} | {{Template:StringTokenizer:RestOfString syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%string</th> | <tr><th>%string</th> | ||
<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>stringTokenizer</th> | <tr><th>stringTokenizer</th> | ||
<td>A <var>StringTokenizer</var> object | <td>A <var>StringTokenizer</var> object.</td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>The <var>RestOfString</var> operation does not advance the NextPosition value. | <li>The <var>RestOfString</var> operation does not advance the <var>NextPosition</var> value. | ||
<li><var>RestOfString</var> depends only on the value of the most recent NextPosition | |||
or [[NextChar (StringTokenizer function)|NextChar]] call; it | <li><var>RestOfString</var> depends only on the value of the most recent <var>NextPosition</var> | ||
is independent of the values of [[CurrentToken (StringTokenizer function)|CurrentToken]] | or <var>[[NextChar (StringTokenizer function)|NextChar]]</var> call; it | ||
and [[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]]. | is independent of the values of <var>[[CurrentToken (StringTokenizer function)|CurrentToken]]</var> | ||
<li>If the value of [[AtEnd (StringTokenizer function)|AtEnd]] is <code>True</code>, | and <var>[[CurrentTokenPosition (StringTokenizer property)|CurrentTokenPosition]]</var>. | ||
<li>If the value of <var>[[AtEnd (StringTokenizer function)|AtEnd]]</var> is <code>True</code>, | |||
issuing <var>RestOfString</var> 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 <var>[[StartOfString (StringTokenizer function)|StartOfString]]</var> 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 | ||
the current token (this first-character position is returned by CurrentTokenPosition). | the current token (this first-character position is returned by <var>CurrentTokenPosition</var>). | ||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
The following request fragment shows that consecutive <var>RestOfString</var> 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 <var>NextPosition</var> value, and it shows that | ||
<var>RestOfString</var> 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: | ||
<p class="code">%tok:string = 'restOfString example' | <p class="code">%tok:string = 'restOfString example' | ||
[[Targeted Text statements#AuditText, PrintText, and TraceText|PrintText]] {%tok:nextToken} | |||
printText {%tok:restOfString} | printText {%tok:restOfString} | ||
printText {%tok:restOfString} | printText {%tok:restOfString} |
Latest revision as of 20:45, 15 November 2012
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. |
---|---|
stringTokenizer | A StringTokenizer object. |
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 \\