Spaces (StringTokenizer property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
<span style="font-size:120%; color:black"><b>Characters to be interpreted as token-delimiting whitespace</b></span>
{{Template:StringTokenizer:Spaces subtitle}}
[[Category:StringTokenizer methods|Spaces property]]
<!--DPL?? Category:StringTokenizer methods|Spaces property: Characters which are the token-delimiting "whitespace" charact-->
<!--DPL?? Category:System methods|Spaces (StringTokenizer property): Characters which are the token-delimiting "whitespace" charact-->
<p>
Spaces is a member of the [[StringTokenizer class]].
</p>


This readWrite property returns or sets the characters that are recognized as
This readWrite property returns or sets the characters that are recognized as
&ldquo;whitespace&rdquo;characters, that is, as characters that separate tokens.
"whitespace"characters, that is, as characters that separate tokens.
Such a character is also called a &ldquo;non-token delimiter,&rdquo;
Such a character is also called a "non-token delimiter,"
because it is a delimiter that is not itself a token.
because it is a delimiter that is not itself a token.


You can specify &ldquo;token delimiters,&rdquo; which are delimiters that are also tokens,
You can specify "token delimiters," which are delimiters that are also tokens,
using the [[TokenChars (StringTokenizer property)|TokenChars]] property or the [[New (StringTokenizer constructor)|New]] constructor TokenChars parameter.
using the [[TokenChars (StringTokenizer property)|TokenChars]] property or the [[New (StringTokenizer constructor)|New]] constructor TokenChars parameter.


Line 19: Line 13:
In that case, the spaces become non-delimiters.
In that case, the spaces become non-delimiters.


===Syntax===
==Syntax==
  %string = %tok:Spaces
{{Template:StringTokenizer:Spaces syntax}}
 
  %tok:Spaces = %string
===Syntax terms===
===Syntax terms===
<dl>
<dl>
Line 37: Line 29:


</dl>
</dl>
===Usage Notes===
==Usage notes==
<ul>
<ul>
<li>The Spaces characters are initially settable in the [[New (StringTokenizer constructor)|New]] call that creates the tokenizer instance.
<li>The Spaces characters are initially settable in the [[New (StringTokenizer constructor)|New]] call that creates the tokenizer instance.
Line 43: Line 35:
one of either the Quotes characters or the TokenChars characters.
one of either the Quotes characters or the TokenChars characters.
</ul>
</ul>
===Examples===
==Examples==


In the following example, a Stringtokenizer object is instantiated
In the following example, a Stringtokenizer object is instantiated
Line 74: Line 66:
     %tok:nextToken is {x Z}
     %tok:nextToken is {x Z}
</pre>
</pre>
==See also==
{{Template:StringTokenizer:Spaces footer}}

Revision as of 19:54, 6 February 2011

Characters to be interpreted as token-delimiting whitespace (StringTokenizer class)


This readWrite property returns or sets the characters that are recognized as "whitespace"characters, that is, as characters that separate tokens. Such a character is also called a "non-token delimiter," because it is a delimiter that is not itself a token.

You can specify "token delimiters," which are delimiters that are also tokens, using the TokenChars property or the New constructor TokenChars parameter.

One or multiple consecutive whitespace characters mark the end or beginning of a token, except when these spaces are part of a quoted region. In that case, the spaces become non-delimiters.

Syntax

%currentString = stringTokenizer:Spaces stringTokenizer:Spaces = newString

Syntax terms

%string
A string variable to contain the returned value of the current whitespace characters or to be set as the new value(s). The default value for a new tokenizer instance is a blank character. If you are setting Spaces, each character in the string is a space character — that is, you may not separate characters — and no character may repeat (except for apostrophe, which may be doubled).
%tok
A StringTokenizer object variable.

Usage notes

  • The Spaces characters are initially settable in the New call that creates the tokenizer instance.
  • No character can be one of the Spaces characters and also one of either the Quotes characters or the TokenChars characters.

Examples

In the following example, a Stringtokenizer object is instantiated with the default parameter settings for the New constructor. Then the input string's tokens are returned in sequence:

    %tok is object stringtokenizer
    %tok = new
    %tok:string = 'Bad,F  ?3mO ,7,{x Z}'
    repeat while not %tok:atEnd
       printText {~} is {%tok:nextToken}
    end repeat

The resulting tokens, which were delimited by the default space character (blank), are:

    %tok:nextToken is Bad,F
    %tok:nextToken is ?3mO
    %tok:nextToken is ,7,{x
    %tok:nextToken is Z}

If instead the tokenizer object is instantiated with a comma as the space character
(%tok = new(Spaces=',')), the resulting tokens are:

    %tok:nextToken is Bad
    %tok:nextToken is F  ?3mO
    %tok:nextToken is 7
    %tok:nextToken is {x Z}

See also