FoldDoubledQuotes (StringTokenizer property): Difference between revisions
m (→Syntax terms) |
mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 9: | Line 9: | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%currentBoolean</th> | <tr><th>%currentBoolean</th> | ||
<td>An enumeration object of type <var>[[Boolean enumeration|Boolean]]</var> to contain the value of <var>FoldDoubledQuotes | <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> | ||
Line 21: | Line 21: | ||
<ul> | <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: | <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> | <p class="output">Please, don't go</p> | ||
The doubled, or escaped, apostrophe is implicitly folded to a single apostrophe. | 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> | 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 result is: <p class="output">Please, don"t go</p> | ||
The escaped double quotation mark is implicitly folded to one double quotation mark. | The escaped double quotation mark is implicitly folded to one double quotation mark. | ||
Line 43: | Line 43: | ||
</p> | </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: | 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> | <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. | <li>If <var>[[RemoveQuotes (StringTokenizer property)|RemoveQuotes]]</var> is set to <code>True</code>, folded quotes are removed. | ||
</ul> | </ul> |
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):
The result is:Print "Please, don""t go"
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.