QuotesBreak (StringTokenizer property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
{{Template:StringTokenizer:QuotesBreak subtitle}}
{{Template:StringTokenizer:QuotesBreak subtitle}}


This page is [[under construction]].
<var>[[QuotesBreak (StringTokenizer property)|QuotesBreak]]</var> determines whether quotes are considered     
boundaries of tokens. The string <code>peanut"butter"</code> will tokenize to <code>peanut</code> and
<code>butter</code> when <var>QuotesBreak</var> is true. Otherwise it will tokenize to <code>peanutbutter</code>
(assuming <var>[[RemoveQuotes (StringTokenizer property)|RemoveQuotes]]</var> is set).  
 
==Syntax==
==Syntax==
{{Template:StringTokenizer:QuotesBreak syntax}}
{{Template:StringTokenizer:QuotesBreak syntax}}
Line 7: Line 11:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%boolean</th>
<tr><th>%boolean</th>
<td>An enumeration object of type <var>Boolean</var> to contain the returned value of <var>CurrentQuoted</var>.
<td>An enumeration object of type <var>Boolean</var> to contain the returned value of <var>CurrentQuoted</var>. The default value is <var>True</var>.


For more information about <var>Boolean</var> enumerations, see [[Enumerations#Using_Boolean_enumerations|"Using Boolean Enumerations"]].</td></tr>
For more information about <var>Boolean</var> enumerations, see [[Enumerations#Using_Boolean_enumerations|"Using Boolean Enumerations"]].</td></tr>
Line 16: Line 20:


==Usage notes==
==Usage notes==
<ul>
<li>The <var>[[Quotes (StringTokenizer property)|Quotes]]</var> characters are initially settable in the <var>[[New (StringTokenizer constructor)|New]]</var> call that creates the tokenizer instance.
<li>The <var>[[RemoveQuotes (StringTokenizer property)|RemoveQuotes]]</var> property controls whether
quotes are removed from the returned values of quoted tokens.
</ul>
==Examples==
==Examples==
In this example, the string <code>fire"works"</code> is either one or two tokens, depending on the setting of <var>QuotesBreak</var>:
<p class="code">b
%tok is object StringTokenizer
%tok = new(quotes='"')
%tok:string = 'fire"works"'         
PrintText {~} is: {%tok:quotesbreak}
repeat while %tok:notAtEnd       
  printtext {~} = {%tok:nextToken}
end repeat
%tok:string = 'fire"works"'         
%tok:quotesbreak = False             
PrintText {~} is: {%tok:quotesbreak}
repeat while %tok:notAtEnd       
  printtext {~} = {%tok:nextToken}
end repeat
end </p>
The result is:
<p class="output">%tok:quotesbreak is: True 
%tok:nextToken = fire
%tok:nextToken = works 
%tok:quotesbreak is: False
%tok:nextToken = fireworks
</p>
==See also==
==See also==
{{Template:StringTokenizer:QuotesBreak footer}}
{{Template:StringTokenizer:QuotesBreak footer}}

Revision as of 00:00, 5 July 2012

Do quotes break the current token? (StringTokenizer class)

[Introduced in Sirius Mods 7.8]


QuotesBreak determines whether quotes are considered boundaries of tokens. The string peanut"butter" will tokenize to peanut and butter when QuotesBreak is true. Otherwise it will tokenize to peanutbutter (assuming RemoveQuotes is set).

Syntax

%currentBoolean = stringTokenizer:QuotesBreak stringTokenizer:QuotesBreak = newBoolean

Syntax terms

%boolean An enumeration object of type Boolean to contain the returned value of CurrentQuoted. The default value is True. For more information about Boolean enumerations, see "Using Boolean Enumerations".
stringTokenizer A StringTokenizer object expression.

Usage notes

  • The Quotes characters are initially settable in the New call that creates the tokenizer instance.
  • The RemoveQuotes property controls whether quotes are removed from the returned values of quoted tokens.

Examples

In this example, the string fire"works" is either one or two tokens, depending on the setting of QuotesBreak:

b %tok is object StringTokenizer %tok = new(quotes='"') %tok:string = 'fire"works"' PrintText {~} is: {%tok:quotesbreak} repeat while %tok:notAtEnd printtext {~} = {%tok:nextToken} end repeat %tok:string = 'fire"works"' %tok:quotesbreak = False PrintText {~} is: {%tok:quotesbreak} repeat while %tok:notAtEnd printtext {~} = {%tok:nextToken} end repeat end

The result is:

%tok:quotesbreak is: True %tok:nextToken = fire %tok:nextToken = works %tok:quotesbreak is: False %tok:nextToken = fireworks

See also