CompressSpaces (StringTokenizer property)

From m204wiki
Revision as of 16:46, 15 November 2012 by JAL (talk | contribs)
Jump to navigation Jump to search

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