Quotes (StringTokenizer property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 14: Line 14:
<tr><th>%chars</th>
<tr><th>%chars</th>
<td>A string variable to contain the returned value of the current quotation characters or to be set as the new value. The default value for a new tokenizer is a null string.
<td>A string variable to contain the returned value of the current quotation characters or to be set as the new value. The default value for a new tokenizer is a null string.
  If you are setting Quotes, each character in the string is a quotation character &mdash; that is, you may not separate characters &mdash; and no character may repeat (except for apostrophe, which may be doubled). </td></tr>
  If you are setting <var>Quotes</var>, each character in the string is a quotation character &mdash; that is, you may not separate characters &mdash; and no character may repeat (except for apostrophe, which may be doubled). </td></tr>
<tr><th>%tok</th>
<tr><th>%tok</th>
<td>A StringTokenizer object variable.</td></tr>
<td>A <var>StringTokenizer</var> object variable.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>No character can be one of the Quotes characters and also be
<li>No character can be one of the <var>Quotes</var> characters and also be
one of either the Spaces characters or the TokenChars characters.
one of either the Spaces characters or the TokenChars characters.
<li>The Quotes characters are initially settable in the [[New (StringTokenizer constructor)|New]] call that creates the tokenizer instance.
<li>The <var>Quotes</var> characters are initially settable in the [[New (StringTokenizer constructor)|New]] call that creates the tokenizer instance.
<li>A quotation character may participate in only one quoted region.
<li>A quotation character may participate in only one quoted region.
The first quotation character from the beginning of the tokenization string is
The first quotation character from the beginning of the tokenization string is
Line 35: Line 35:


The following request fragment employs two quotation characters, and
The following request fragment employs two quotation characters, and
it uses the RemoveQuotes method to include the quotation characters
it uses the Remove<var>Quotes</var> method to include the quotation characters
in the returned tokens:
in the returned tokens:
<pre>
<pre>
     %tok = new(Quotes='"+')
     %tok = new(<var>Quotes</var>='"+')
     %tok:string = '+This  Quotes  example+ is "trivial"'
     %tok:string = '+This  <var>Quotes</var> example+ is "trivial"'
     %tok:removeQuotes = False
     %tok:remove<var>Quotes</var> = False
     Print %tok:nextToken
     Print %tok:nextToken
     Print %tok:nextToken
     Print %tok:nextToken
Line 48: Line 48:
The result is:
The result is:
<pre>
<pre>
     +This  Quotes  example+
     +This  <var>Quotes</var> example+
     is
     is
     "trivial"
     "trivial"

Revision as of 21:47, 6 February 2011

Characters to be interpreted as quotes (StringTokenizer class)


This readWrite property returns or sets the characters that are recognized as quotation characters. The text between each disjoint pair of identical quotation characters (a "quoted region") is treated as a single token, and any delimiter characters (Quote, Space, or TokenChar) within a quoted region are treated as non-delimiters.

Syntax

%currentString = stringTokenizer:Quotes stringTokenizer:Quotes = newString

Syntax terms

%chars A string variable to contain the returned value of the current quotation characters or to be set as the new value. The default value for a new tokenizer is a null string. If you are setting Quotes, each character in the string is a quotation 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

  • No character can be one of the Quotes characters and also be one of either the Spaces characters or the TokenChars characters.
  • The Quotes characters are initially settable in the New call that creates the tokenizer instance.
  • A quotation character may participate in only one quoted region. The first quotation character from the beginning of the tokenization string is paired with the following identical quotation character in the string. An unpaired quotation character causes a request cancellation.
  • A quoted region is not affected by the TokensToLower and TokensToUpper properties.
  • The RemoveQuotes property controls whether quotes are removed from the returned values of quoted tokens.

Examples

The following request fragment employs two quotation characters, and it uses the RemoveQuotes method to include the quotation characters in the returned tokens:

    %tok = new(<var>Quotes</var>='"+')
    %tok:string = '+This  <var>Quotes</var>  example+ is "trivial"'
    %tok:remove<var>Quotes</var> = False
    Print %tok:nextToken
    Print %tok:nextToken
    Print %tok:nextToken

The result is:

    +This  <var>Quotes</var>  example+
    is
    "trivial"

See also