FoldDoubledQuotes (StringTokenizer property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Automatically generated page update)
 
mNo edit summary
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Template:StringTokenizer:FoldDoubledQuotes subtitle}}
{{Template:StringTokenizer:FoldDoubledQuotes subtitle}}


This page is [[under construction]].
<var>FoldDoubledQuotes</var> provides implicit folding of a doubled <var>Quotes</var> character, which is common in <var class="product">User Language</var> but not the default for the <var>StringTokenizer</var>.
 
==Syntax==
==Syntax==
{{Template:StringTokenizer:FoldDoubledQuotes syntax}}
{{Template:StringTokenizer:FoldDoubledQuotes syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%boolean</th><td><var>Boolean</var> value</td></tr>
<tr><th>%currentBoolean</th>
<td>An enumeration object of type <var>[[Boolean enumeration|Boolean]]</var> to contain the value of <var>FoldDoubledQuotes</var>. The default value for a new tokenizer instance is <var>False</var>.</td></tr>
 
<tr><th>stringTokenizer</th>
<tr><th>stringTokenizer</th>
<td>StringTokenizer object</td></tr>
<td>A <var>StringTokenizer</var> object variable.</td></tr>
 
<tr><th>newBoolean</th>
<td>A <var>Boolean</var> enumeration value.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
==Examples==
<ul>
<li>The practice of doubling an apostrophe ( ' ) to yield a single apostrophe is common in <var class="product">User Language</var> <var>Print</var> statements. For example, the result of <code>Print 'Please, don<nowiki>''</nowiki>t go'</code> is:
<p class="output">Please, don't go</p>
The doubled, or escaped, apostrophe is implicitly folded to a single apostrophe.
Similarly, if double quotation marks instead of the apostrophes are used to indicate a quoted string (as is [[V7.8 changes affecting all or multiple products#Double quotation marks for quoted strings|allowed]] as of <var class="product">Sirius Mods</var> version 7.8): <code>Print "Please, don""t go"</code>
The result is: <p class="output">Please, don"t go</p>
The escaped double quotation mark is implicitly folded to one double quotation mark.
The <var>StringTokenizer</var>, however, does not perform this implicit folding if it encounters a doubled <var>[[Quotes (StringTokenizer property)|Quotes]]</var> character within a quoted region. For example:
<p class="code">b
%toke is object StringTokenizer
%toke = new(quotes='"')
%toke:string = '"Please, don""t go"'
repeat while %toke:notAtEnd
  printtext {~} = '{%toke:nextToken}'
end repeat
end
</p>
The result of this request is:
<p class="output">%toke:nextToken = 'Please, don'
%toke:nextToken = 't go'
</p>
However, if <var>FoldDoubledQuotes</var> is set to <var>True</var> (which is not the default), the tokenizer considers two adjacent <var>Quotes</var> characters within a quoted region ''that is begun by the same <var>Quotes</var> character'' to be an escape sequence for a single quotation character, and the result of tokenizing <code>%toke:string = '"Please, don""t go"'</code> from the previous request is:
<p class="output">Please, don"t go</p>
 
<li>If <var>[[RemoveQuotes (StringTokenizer property)|RemoveQuotes]]</var> is set to <code>True</code>, folded quotes are removed.
</ul>
 
==See also==
==See also==
{{Template:StringTokenizer:FoldDoubledQuotes footer}}
{{Template:StringTokenizer:FoldDoubledQuotes footer}}

Latest revision as of 17:34, 15 November 2012

Doubled quotes treated as escaped quote char (StringTokenizer class)

[Introduced in Sirius Mods 7.8]


FoldDoubledQuotes provides implicit folding of a doubled Quotes character, which is common in User Language but not the default for the StringTokenizer.

Syntax

%currentBoolean = stringTokenizer:FoldDoubledQuotes stringTokenizer:FoldDoubledQuotes = newBoolean

Syntax terms

%currentBoolean An enumeration object of type Boolean to contain the value of FoldDoubledQuotes. The default value for a new tokenizer instance is False.
stringTokenizer A StringTokenizer object variable.
newBoolean A Boolean enumeration value.

Usage notes

  • The practice of doubling an apostrophe ( ' ) to yield a single apostrophe is common in User Language Print statements. For example, the result of Print 'Please, don''t go' is:

    Please, don't go

    The doubled, or escaped, apostrophe is implicitly folded to a single apostrophe. Similarly, if double quotation marks instead of the apostrophes are used to indicate a quoted string (as is allowed as of Sirius Mods version 7.8): Print "Please, don""t go"

    The result is:

    Please, don"t go

    The escaped double quotation mark is implicitly folded to one double quotation mark.

    The StringTokenizer, however, does not perform this implicit folding if it encounters a doubled Quotes character within a quoted region. For example:

    b %toke is object StringTokenizer %toke = new(quotes='"') %toke:string = '"Please, don""t go"' repeat while %toke:notAtEnd printtext {~} = '{%toke:nextToken}' end repeat end

    The result of this request is:

    %toke:nextToken = 'Please, don' %toke:nextToken = 't go'

    However, if FoldDoubledQuotes is set to True (which is not the default), the tokenizer considers two adjacent Quotes characters within a quoted region that is begun by the same Quotes character to be an escape sequence for a single quotation character, and the result of tokenizing %toke:string = '"Please, don""t go"' from the previous request is:

    Please, don"t go

  • If RemoveQuotes is set to True, folded quotes are removed.

See also