AtEnd (StringTokenizer function): Difference between revisions
m (1 revision) |
m (1 revision) |
||
Line 13: | Line 13: | ||
<tr><th>%bool</th> | <tr><th>%bool</th> | ||
<td>An enumeration object of type Boolean to contain the returned value of <var>AtEnd</var>. | <td>An enumeration object of type Boolean to contain the returned value of <var>AtEnd</var>. | ||
<p class="code">For more information about Boolean enumerations, see [[Using Boolean enumerations]]. </td></tr> | |||
</p> | |||
<tr><th>%tok</th> | <tr><th>%tok</th> | ||
<td>A <var>StringTokenizer</var> object variable.</td></tr> | <td>A <var>StringTokenizer</var> object variable.</td></tr> | ||
Line 23: | Line 24: | ||
In the following code sequence, the return from <var>AtEnd</var> is <tt>True</tt> | In the following code sequence, the return from <var>AtEnd</var> is <tt>True</tt> | ||
and the position is not at the end of the string: | and the position is not at the end of the string: | ||
< | <p class="code">%tok:string = 'example ' | ||
%tok:nextPosition = 10 | |||
%tok:atEnd | |||
</p> | |||
</ | |||
<li>[[NotAtEnd (StringTokenizer function)|NotAtEnd]] is the reverse of <var>AtEnd</var>: | <li>[[NotAtEnd (StringTokenizer function)|NotAtEnd]] is the reverse of <var>AtEnd</var>: | ||
it returns a value of <tt>False</tt> | it returns a value of <tt>False</tt> | ||
Line 36: | Line 36: | ||
The following request selects the string's tokens one after another until | The following request selects the string's tokens one after another until | ||
the end of the string is detected: | the end of the string is detected: | ||
< | <p class="code">begin | ||
%tok is object stringtokenizer | |||
%tok = new | |||
%tok:string = 'Content-Type: text/plain; charset="US-ASCII"' | |||
repeat while not %tok:atEnd | |||
printText {~} is {%tok:nextToken} | |||
end repeat | |||
end | |||
</p> | |||
</ | |||
The result is: | The result is: | ||
< | <p class="output">%tok:nextToken is Content-Type: | ||
%tok:nextToken is text/plain; | |||
%tok:nextToken is charset="US-ASCII" | |||
</p> | |||
</ | |||
==See also== | ==See also== | ||
{{Template:StringTokenizer:AtEnd footer}} | {{Template:StringTokenizer:AtEnd footer}} |
Revision as of 21:48, 6 February 2011
Is current tokenizing position at the end of the string? (StringTokenizer class)
This method returns a Boolean value that indicates whether
the present tokenizing position is immediately after the last token.
The value is True if the position at after the last token;
otherwise it is False.
The tokenizing position is given by NextPosition.
Syntax
%boolean = stringTokenizer:AtEnd
Syntax terms
%bool | An enumeration object of type Boolean to contain the returned value of AtEnd.
For more information about Boolean enumerations, see Using Boolean enumerations. |
---|---|
%tok | A StringTokenizer object variable. |
Usage notes
- The current tokenizing position may be after the last token but
not necessarily at the end of the token string.
In the following code sequence, the return from AtEnd is True
and the position is not at the end of the string:
%tok:string = 'example ' %tok:nextPosition = 10 %tok:atEnd
- NotAtEnd is the reverse of AtEnd: it returns a value of False if the current tokenizing position is at the end of the string.
Examples
The following request selects the string's tokens one after another until the end of the string is detected:
begin %tok is object stringtokenizer %tok = new %tok:string = 'Content-Type: text/plain; charset="US-ASCII"' repeat while not %tok:atEnd printText {~} is {%tok:nextToken} end repeat end
The result is:
%tok:nextToken is Content-Type: %tok:nextToken is text/plain; %tok:nextToken is charset="US-ASCII"