CompressSpaces (StringTokenizer property)

From m204wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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