AtEnd (StringTokenizer function): Difference between revisions
Jump to navigation
Jump to search
m (→Usage notes) |
m (→Syntax terms) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Template:StringTokenizer:AtEnd subtitle}} | {{Template:StringTokenizer:AtEnd subtitle}} | ||
This method returns a Boolean value that is < | This method returns a <var>[[Enumerations#Using_Boolean_enumerations|Boolean]]</var> value that is <var>True</var> if | ||
no tokens remain starting from <var>[[NextPosition (StringTokenizer property)|NextPosition]]</var>. | no tokens remain starting from <var>[[NextPosition (StringTokenizer property)|NextPosition]]</var>. | ||
Line 11: | Line 11: | ||
<tr><th>%boolean</th> | <tr><th>%boolean</th> | ||
<td>An enumeration object of type <var>Boolean</var> to contain the returned value of <var>AtEnd</var>. The result is <code>true</code> if no tokens remain, starting from <var>NextPosition</var>, and <code>false</code> if any tokens remain. | <td>An enumeration object of type <var>Boolean</var> to contain the returned value of <var>AtEnd</var>. The result is <code>true</code> if no tokens remain, starting from <var>NextPosition</var>, and <code>false</code> if any tokens remain. | ||
<tr><th>stringTokenizer</th> | <tr><th>stringTokenizer</th> | ||
Line 20: | Line 18: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>It is illegal to scan for a token past the <var>CurrentToken</var> if <var>AtEnd</var> is <code>true</code>. | <li>It is illegal to scan for a token past the <var>[[CurrentToken (StringTokenizer function)|CurrentToken]]</var> if <var>AtEnd</var> is <code>true</code>. | ||
<li>For <var>Spaces</var> tokenization, a token remains if there are any non-<var>Spaces</var> characters remaining at or | |||
<li>For <var>[[Spaces (StringTokenizer property)|Spaces]]</var> tokenization, a token remains if there are any non-<var>Spaces</var> characters remaining at or | |||
after <var>NextPosition</var>. | after <var>NextPosition</var>. | ||
<li>For <var>Separators</var> tokenization, a token remains if either: | <li>For <var>[[Separators (StringTokenizer property)|Separators]]</var> tokenization, a token remains if either: | ||
<ul> | <ul> | ||
<li><var>NextPosition</var> is less than or equal to the length of the <var>String</var>. | <li><var>NextPosition</var> is less than or equal to the length of the <var>String</var>. | ||
Line 30: | Line 29: | ||
the last method which located a token found a separator at the end of the <var>String</var>. | the last method which located a token found a separator at the end of the <var>String</var>. | ||
</ul> | </ul> | ||
<li><var>NextPosition</var> may be after the last token but | |||
not necessarily at the end of the token string. | <li><var>NextPosition</var> may be after the last token but not necessarily at the end of the token string. | ||
In the following code sequence, the return from <var>AtEnd</var> is <code>true</code> | In the following code sequence, the return from <var>AtEnd</var> is <code>true</code> | ||
and the position is not at the end of the string: | and the position is not at the end of the string: | ||
Line 38: | Line 37: | ||
printText {~=%tok:atEnd} | printText {~=%tok:atEnd} | ||
</p> | </p> | ||
<li><var>[[NotAtEnd (StringTokenizer function)|NotAtEnd]]</var> is the reverse of <var>AtEnd</var>: | <li><var>[[NotAtEnd (StringTokenizer function)|NotAtEnd]]</var> is the reverse of <var>AtEnd</var>: | ||
it returns <code>true</code> | it returns <code>true</code> if any tokens remain starting with <var>NextToken</var>. | ||
if any tokens remain starting with <var>NextToken</var>. | |||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
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: |
Latest revision as of 20:09, 14 October 2014
Is current tokenizing position at the end of the string? (StringTokenizer class)
This method returns a Boolean value that is True if
no tokens remain starting from NextPosition.
Syntax
%boolean = stringTokenizer:AtEnd
Syntax terms
%boolean | An enumeration object of type Boolean to contain the returned value of AtEnd. The result is true if no tokens remain, starting from NextPosition, and false if any tokens remain.
|
---|---|
stringTokenizer | A stringTokenizer object. |
Usage notes
- It is illegal to scan for a token past the CurrentToken if AtEnd is
true
. - For Spaces tokenization, a token remains if there are any non-Spaces characters remaining at or after NextPosition.
- For Separators tokenization, a token remains if either:
- NextPosition is less than or equal to the length of the String.
- Either a token has not been located in the String, or the last method which located a token found a separator at the end of the String.
- NextPosition 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 = 'example ':stringTokenizer %tok:nextPosition = 8 printText {~=%tok:atEnd}
- NotAtEnd is the reverse of AtEnd:
it returns
true
if any tokens remain starting with NextToken.
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"