CurrentQuoted (StringTokenizer function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:StringTokenizer:CurrentQuoted subtitle}}
{{Template:StringTokenizer:CurrentQuoted subtitle}}


This method returns a Boolean value that indicates whether
This method returns a <var>[[Boolean enumeration|Boolean]]</var> value that indicates whether
the current token is a quoted token.
the current token is a quoted token.
A quoted token contains all the characters between a pair of identical
A quoted token contains all the characters between a pair of identical
Line 8: Line 8:
The <var>CurrentQuoted</var> value is <code>True</code> if the current token is quoted;
The <var>CurrentQuoted</var> value is <code>True</code> if the current token is quoted;
otherwise it is <code>False</code>.
otherwise it is <code>False</code>.
==Syntax==
==Syntax==
{{Template:StringTokenizer:CurrentQuoted syntax}}
{{Template:StringTokenizer:CurrentQuoted syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%boolean</th>
<tr><th>%boolean</th>
<td>An enumeration object of type <var>Boolean</var> to contain the returned value of <var>CurrentQuoted</var>.
<td>An enumeration object of type <var>Boolean</var> to contain the returned value of <var>CurrentQuoted</var>.</td></tr>


For more information about <var>Boolean</var> enumerations, see [[Enumerations#Using_Boolean_enumerations|"Using Boolean Enumerations"]]. </td></tr>
<tr><th>stringTokenizer</th>
<tr><th>stringTokenizer</th>
<td>A <var>StringTokenizer</var> object expression.</td></tr>
<td>A <var>StringTokenizer</var> object expression.</td></tr>
Line 22: Line 23:
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>The Quotes characters are initially settable in the [[New (StringTokenizer constructor)|New]]) call that creates the tokenizer instance.
<li>The <var>[[Quotes (StringTokenizer property)|Quotes]]</var> characters are initially settable in the <var>[[New (StringTokenizer constructor)|New]]</var> 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
paired with the following identical quotation character in the string.
paired with the following identical quotation character in the string.
An unpaired quotation character causes a request cancellation.
An unpaired quotation character causes a request cancellation.
<li>A quoted region is not affected by the [[TokensToLower (StringTokenizer property)|TokensToLower]]
 
and [[TokensToUpper (StringTokenizer property)|TokensToUpper]] properties.
<li>A quoted region is not affected by the <var>[[TokensToLower (StringTokenizer property)|TokensToLower]]</var>
<li>The [[RemoveQuotes (StringTokenizer property)|RemoveQuotes]] property controls whether
and <var>[[TokensToUpper (StringTokenizer property)|TokensToUpper]]</var> properties.
 
<li>The <var>[[RemoveQuotes (StringTokenizer property)|RemoveQuotes]]</var> property controls whether
quotes are removed from the returned values of quoted tokens.
quotes are removed from the returned values of quoted tokens.
</ul>
</ul>


==Examples==
==Examples==
 
<ol>
In the following request fragment, the selection of a quoted token
<li>In the following request fragment, the selection of a quoted token
is verified by a <var>CurrentQuoted</var> call:
is verified by a <var>CurrentQuoted</var> call:
<p class="code">%tok = new(quotes='"')
<p class="code">%tok = new(quotes='"')
%tok:string = 'simple "quoted tokens" example'
%tok:string = 'simple "quoted tokens" example'
PrintText {~} is {%tok:nextToken}
[[Targeted Text statements#AuditText, PrintText, and TraceText|PrintText]] {~} is: {%tok:nextToken}
PrintText {~} is {%tok:nextToken}
PrintText {~} is: {%tok:nextToken}
PrintText {~} is {%tok:currentToken}
PrintText {~} is: {%tok:currentToken}
PrintText {~} is {%tok:currentQuoted}
PrintText {~} is: {%tok:currentQuoted}
</p>
</p>


The result is:
The result is:
<p class="output">%tok:nextToken is simple
<p class="output">%tok:nextToken is: simple
%tok:nextToken is quoted tokens
%tok:nextToken is: quoted tokens
%tok:currentToken is quoted tokens
%tok:currentToken is: quoted tokens
%tok:currentQuoted is True
%tok:currentQuoted is: True
</p>
</p>
'''Note:'''
<p class="note">'''Note:'''
Using the PrintText statement is described in [[Targeted Text statements|"Targeted Text statements"]].
Printing an enumeration value is described in the <var>ToString</var> property discussion in [[Enumerations#printenum|Usage notes on the Enumerations page]]. </p>
Printing an enumeration value is described in [[Enumerations#printenum|ToString property "Usage notes"]].
 
<li>If <var>[[QuotesBreak (StringTokenizer property)|QuotesBreak]]</var> is <code>False</code> and only part of a token is quoted, <var>CurrentQuoted</var> returns <code>True</code> only if, unlike below, the quoted part is at the beginning of the token:
<p class="code">%tok = new(quotes='"', Separators=',')
%tok:quotesbreak = False             
 
%tok:string = 'about the, ben"jamins"'
PrintText {~} is: {%tok:nextToken}   
PrintText {~} is: {%tok:nextToken}   
PrintText {~} is: {%tok:currentQuoted}  </p>
 
The result is:
<p class="output">%tok:nextToken is: about the
%tok:nextToken is: benjamins
%tok:currentQuoted is: False </p>
 
If the tokenizer string in this example were <code>about the, "ben"jamins</code>, <var>CurrentQuoted</var> would return <code>True</code> in accord with the <var class="product">SOUL</var> concept that a quoted token does not end until it reaches a space or separator character after the closing quotation mark character. For further discussion of <var class="product">SOUL</var> quoted-string handling, see [[Double quotation marks for quoted strings]].


==See also==
==See also==
{{Template:StringTokenizer:CurrentQuoted footer}}
{{Template:StringTokenizer:CurrentQuoted footer}}

Latest revision as of 23:17, 10 October 2014

Is current token a quoted token? (StringTokenizer class)


This method returns a Boolean value that indicates whether the current token is a quoted token. A quoted token contains all the characters between a pair of identical quotation characters.

The CurrentQuoted value is True if the current token is quoted; otherwise it is False.

Syntax

%boolean = stringTokenizer:CurrentQuoted

Syntax terms

%boolean An enumeration object of type Boolean to contain the returned value of CurrentQuoted.
stringTokenizer A StringTokenizer object expression.

Usage notes

  • 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

  1. In the following request fragment, the selection of a quoted token is verified by a CurrentQuoted call:

    %tok = new(quotes='"') %tok:string = 'simple "quoted tokens" example' PrintText {~} is: {%tok:nextToken} PrintText {~} is: {%tok:nextToken} PrintText {~} is: {%tok:currentToken} PrintText {~} is: {%tok:currentQuoted}

    The result is:

    %tok:nextToken is: simple %tok:nextToken is: quoted tokens %tok:currentToken is: quoted tokens %tok:currentQuoted is: True

    Note: Printing an enumeration value is described in the ToString property discussion in Usage notes on the Enumerations page.

  2. If QuotesBreak is False and only part of a token is quoted, CurrentQuoted returns True only if, unlike below, the quoted part is at the beginning of the token:

    %tok = new(quotes='"', Separators=',') %tok:quotesbreak = False %tok:string = 'about the, ben"jamins"' PrintText {~} is: {%tok:nextToken} PrintText {~} is: {%tok:nextToken} PrintText {~} is: {%tok:currentQuoted}

    The result is:

    %tok:nextToken is: about the %tok:nextToken is: benjamins %tok:currentQuoted is: False

    If the tokenizer string in this example were about the, "ben"jamins, CurrentQuoted would return True in accord with the SOUL concept that a quoted token does not end until it reaches a space or separator character after the closing quotation mark character. For further discussion of SOUL quoted-string handling, see Double quotation marks for quoted strings.

    See also