CompressSpaces (StringTokenizer property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Automatically generated page update)
 
mNo edit summary
Line 1: Line 1:
{{Template:StringTokenizer:CompressSpaces subtitle}}
{{Template:StringTokenizer:CompressSpaces subtitle}}


This page is [[under construction]].
<var>CompressSpaces</var> compresses a token's intermediate whitespace
to a single whitespace character.  
 
==Syntax==
==Syntax==
{{Template:StringTokenizer:CompressSpaces syntax}}
{{Template:StringTokenizer:CompressSpaces 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>CompressSpaces</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>
</table>
 
<tr><th>newBoolean</th>
<td>A <var>Boolean</var> enumeration value.</td></tr></table>
 
==Usage notes==
==Usage notes==
<ul>
<li>If multiple whitespace
characters are defined, the first character in the <var>Spaces</var> string is the character to which <var>CompressSpaces</var> compresses intermediate whitespace. For example, if <code>Spaces='X '</code>, the token
<code>'foot  ball'</code> will compress to <code>'footXball'</code>.
<li><var>CompressSpaces</var> affects
processing only when one or more <var>Separators</var> characters are set, because otherwise a
token cannot contain internal whitespace.
<li><var>CompressSpaces</var> does not compress quoted data that contains whitespace.
</ul>
==Examples==
==Examples==
Consider the following <code>%toke</code> <var>StringTokenizer</var> string, defined with a blank as the whitespace character and with comma as a non-token [[#The Separators method|separator]] character:
<p class="output">      this,    is  a  compression  , example
</p>
Without compression, repeated calls of <code>%toke:NextToken</code> strip the leading and trailing whitespace and select the following tokens:
<p class="output"> this
is  a  compression
example
</p>
Without compression, that is, with <var>CompressSpaces</var> set to <var>True</var>, the result is:
<p class="output"> this
is a compression
example
</p>
==See also==
==See also==
{{Template:StringTokenizer:CompressSpaces footer}}
{{Template:StringTokenizer:CompressSpaces footer}}

Revision as of 16:19, 5 July 2012

Compress intra-token spaces (StringTokenizer class)

[Introduced in Sirius Mods 7.8]


CompressSpaces compresses a token's intermediate whitespace to a single whitespace character.

Syntax

%currentBoolean = stringTokenizer:CompressSpaces stringTokenizer:CompressSpaces = newBoolean

Syntax terms

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

Usage notes

  • If multiple whitespace characters are defined, the first character in the Spaces string is the character to which CompressSpaces compresses intermediate whitespace. For example, if Spaces='X ', the token 'foot ball' will compress to 'footXball'.
  • CompressSpaces affects processing only when one or more Separators characters are set, because otherwise a token cannot contain internal whitespace.
  • CompressSpaces does not compress quoted data that contains whitespace.


Examples

Consider the following %toke StringTokenizer string, defined with a blank as the whitespace character and with comma as a non-token separator character:

this, is a compression , example

Without compression, repeated calls of %toke:NextToken strip the leading and trailing whitespace and select the following tokens:

this is a compression example

Without compression, that is, with CompressSpaces set to True, the result is:

this is a compression example

See also