CompressSpaces (StringTokenizer property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
Line 17: Line 17:


<tr><th>newBoolean</th>
<tr><th>newBoolean</th>
<td>A <var>[[Boolean enumeration]]</var> value.</td></tr></table>
<td>A <var>Boolean</var> enumeration value.</td></tr></table>


==Usage notes==
==Usage notes==
<ul>
<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
<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>.
<code>foot  ball</code> will compress to <code>footXball</code>.


<li><var>CompressSpaces</var> affects
<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.
processing only when one or more <var>[[Separators (StringTokenizer property)|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.  
<li><var>CompressSpaces</var> does not compress quoted data that contains whitespace.  

Latest revision as of 16:49, 15 November 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