SkipTokens (StringTokenizer subroutine): Difference between revisions
m (1 revision) |
m (1 revision) |
||
Line 12: | Line 12: | ||
the request is cancelled. | the request is cancelled. | ||
The SkipTokens subroutine is available as of version 7.7 of the ''Sirius Mods''. | The <var>SkipTokens</var> subroutine is available as of version 7.7 of the ''Sirius Mods''. | ||
==Syntax== | ==Syntax== | ||
{{Template:StringTokenizer:SkipTokens syntax}} | {{Template:StringTokenizer:SkipTokens syntax}} | ||
Line 18: | Line 18: | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%tok</th> | <tr><th>%tok</th> | ||
<td>A StringTokenizer object variable. </td></tr> | <td>A <var>StringTokenizer</var> object variable. </td></tr> | ||
<tr><th>num</th> | <tr><th>num</th> | ||
<td>A numeric variable that is the number of tokens to skip. The value of ''num'' must be greater than 0 and less than the number of tokens remaining in the tokenizer string.</td></tr> | <td>A numeric variable that is the number of tokens to skip. The value of ''num'' must be greater than 0 and less than the number of tokens remaining in the tokenizer string.</td></tr> | ||
Line 24: | Line 24: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>For a new StringTokenizer instance, issuing NextToken, SkipTokens, | <li>For a new <var>StringTokenizer</var> instance, issuing NextToken, <var>SkipTokens</var>, | ||
or [[FindToken (StringTokenizer function)|FindToken]] is required before | or [[FindToken (StringTokenizer function)|FindToken]] is required before | ||
[[CurrentToken (StringTokenizer function)|CurrentToken]] may be issued without error. | [[CurrentToken (StringTokenizer function)|CurrentToken]] may be issued without error. | ||
Line 30: | Line 30: | ||
==Examples== | ==Examples== | ||
The following code fragment shows multiple SkipTokens calls. | The following code fragment shows multiple <var>SkipTokens</var> calls. | ||
The second call follows a move of the tokenizing position | The second call follows a move of the tokenizing position | ||
to the middle of the initial token in the tokenizer string. | to the middle of the initial token in the tokenizer string. |
Revision as of 21:47, 6 February 2011
Move current token forward a specified number of tokens (StringTokenizer class)
[Introduced in Sirius Mods 7.7]
This method moves the current token and tokenizing position forward in the
tokenizer string the number of tokens specified in the method argument.
Skipping one token is equivalent to executing NextToken;
skipping three tokens is equivalent to executing NextToken three times consecutively.
If a token is found after advancing the designated number of tokens, the tokenizing position in the string is moved after the found token, and CurrentToken will return the found token. If the end of the string occurs before the specified number of tokens, the request is cancelled.
The SkipTokens subroutine is available as of version 7.7 of the Sirius Mods.
Syntax
stringTokenizer:SkipTokens( number) Throws MismatchedQuote, OutOfBounds
Syntax terms
%tok | A StringTokenizer object variable. |
---|---|
num | A numeric variable that is the number of tokens to skip. The value of num must be greater than 0 and less than the number of tokens remaining in the tokenizer string. |
Usage notes
- For a new StringTokenizer instance, issuing NextToken, SkipTokens, or FindToken is required before CurrentToken may be issued without error.
Examples
The following code fragment shows multiple SkipTokens calls. The second call follows a move of the tokenizing position to the middle of the initial token in the tokenizer string.
begin %tok is object stringTokenizer %tok = new %tok:string = 'Here is the skipTokens example.' printText {~} = '{%tok:string}' %tok:skipTokens(3) printText {~} = {%tok:currentToken} printText {~} = {%tok:nextPosition} %tok:nextPosition = 3 %tok:skipTokens(1) printText {~} = {%tok:currentToken} printText {~} = {%tok:nextPosition} %tok:skipTokens(4) printText {~} = {%tok:currentToken} end
The result is:
%tok:string = 'Here is the skipTokens example.' %tok:currentToken = the %tok:nextPosition = 12 %tok:currentToken = re %tok:nextPosition = 5 %tok:currentToken = example. %tok:nextPosition = 32