$Alpha: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (misc cleanup)
(misc cleanup)
Line 1: Line 1:
<p>
<p>
The <var>$Alpha</var> function verifies whether a string is composed only of characters which are valid in the specified (or default) language. A 1 is returned if the condition is true; otherwise, a 0 is returned (for a false condition). A 0 is returned if there are any spaces or punctuation marks in the string, or if the string is null.</p>
The <var>$Alpha</var> function verifies whether a string is composed only of characters which are valid in the specified (or default) language.  
<ul>
<li>1 is returned if the condition is true.</li>
<li>0 is returned if the condition is false; for example:
<ul>
<li>the string contains digits, spaces, or punctuation marks</li>
<li>the string is null</li>
<li>U.S. English characters in a string have accent marks</li>
</ul>
</li>
</ul></p>


==Syntax==
==Syntax==
Line 8: Line 18:
Where:</p>
Where:</p>
<ul>
<ul>
<li><var class="term">string</var> represents the string to be verified. string must be one of:
<li><var class="term">string</var> represents the string to be verified. The string must be one of the following:
<ul>
<ul>
<li>A literal enclosed in quotation marks</li>
<li>A literal enclosed in quotation marks</li>
 
<li>A %variable</li>
<li>%variable</li>
 
<li>A field name without quotation marks. In this case, the function call must be embedded in a <var>FOR EACH RECORD</var> loop where the current value of the field is verified.</li>
<li>A field name without quotation marks. In this case, the function call must be embedded in a <var>FOR EACH RECORD</var> loop where the current value of the field is verified.</li>
</ul></li>
</ul></li>
Line 32: Line 40:
==Examples==
==Examples==
<p>
<p>
The following table has examples of the pattern and language arguments as literals:</p>
The following table has examples of the <var class="term">string</var> and <var class="term">language</var> arguments as literals.</p>
<table>
<table>
<tr class="head">
<tr class="head">
Line 62: Line 70:
</table>
</table>
<p>
<p>
The following request sorts and prints the names of agents whose name contains non alphabetic characters. The quoted asterisk in the <var>$Alpha</var> call causes <var class="product">Model&nbsp;204</var> to verify the contents of the field <code>AGENT</code> against whatever language is indicated by the value of the <var>LANGUSER</var> parameter:</p>
In the following code example, the request sorts and prints the names of agents whose name contains nonalphabetic characters. The quoted asterisk in the <var>$Alpha</var> call causes <var class="product">Model&nbsp;204</var> to verify the contents of the field <code>AGENT</code> against whatever language is indicated by the value of the <var>LANGUSER</var> parameter:</p>
<p class="code">BEGIN
<p class="code">RESET LANGUSER 'FRENCHC'
BEGIN
POL.HOLDERS:  FIND ALL RECORDS FOR WHICH
POL.HOLDERS:  FIND ALL RECORDS FOR WHICH
                 RECTYPE = POLICYHOLDER
                 RECTYPE = POLICYHOLDER

Revision as of 21:27, 3 March 2016

The $Alpha function verifies whether a string is composed only of characters which are valid in the specified (or default) language.

  • 1 is returned if the condition is true.
  • 0 is returned if the condition is false; for example:
    • the string contains digits, spaces, or punctuation marks
    • the string is null
    • U.S. English characters in a string have accent marks

Syntax

The format of the $Alpha function is:

$Alpha(string [,language])

Where:

  • string represents the string to be verified. The string must be one of the following:
    • A literal enclosed in quotation marks
    • A %variable
    • A field name without quotation marks. In this case, the function call must be embedded in a FOR EACH RECORD loop where the current value of the field is verified.
  • The optional language argument specifies the language to use. The language argument is handled as follows:
    • You can enter a literal enclosed in quotation marks or a %variable containing a valid language name. If the value you enter is not a supported language, the request is canceled with the following error message. See the LANGUSER parameter for the valid values.

      M204.2340: INVALID LANGUAGE ARGUMENT: 'language' FOR $FUNCTION: ALPHA

    • If you omit the language argument, Model 204 performs the validation in U.S. English, even if the value of the LANGUSER parameter is not US, and lowercase characters are not recognized.
    • An asterisk enclosed in quotation marks ('*') instructs Model 204 to use the value of the LANGUSER parameter.

Examples

The following table has examples of the string and language arguments as literals.

Function code... Returns...

$alpha('JOHN','US')

1

$alpha('MÂCON','FRENCHC')

1

$alpha('MÂCON','US')

0

$alpha('JOHN SMITH','US')

0

$alpha('ÎLE D'ORLÉANS','FRENCHC')

0

$alpha('12A','US')

0

$alpha('12A','FRENCHC')

0

In the following code example, the request sorts and prints the names of agents whose name contains nonalphabetic characters. The quoted asterisk in the $Alpha call causes Model 204 to verify the contents of the field AGENT against whatever language is indicated by the value of the LANGUSER parameter:

RESET LANGUSER 'FRENCHC' BEGIN POL.HOLDERS: FIND ALL RECORDS FOR WHICH RECTYPE = POLICYHOLDER END FIND FOR EACH RECORD IN POL.HOLDERS IF NOT $alpha (AGENT, '*') THEN PLACE RECORD ON LIST BADNAME END IF END FOR ORDERED.LIST: SORT RECORDS ON LIST BADNAME BY AGENT FOR EACH RECORD IN ORDERED.LIST PRINT AGENT END FOR END

Note: For upward compatibility reasons, $Alpha and $Alphnum do not recognize lowercase English letters as alphabetic characters unless a non-null language parameter is specified.