$Alpha: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
m (typo)
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<p>The $ALPHA 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>
<p>
<b>Syntax</b>
The <var>$Alpha</var> function verifies whether a string is composed only of characters that are valid in the specified (or default) language.  
<p>The format of the $ALPHA function is:</p>
<p class="code">$ALPHA(string <var>[</var>,language<var>]</var>)
</p>
</p>
<p>where:</p>
 
==Syntax==
<p class="syntax"><span class="term">%result</span> = $Alpha(<span class="term">string</span> [,<span class="term">language</span>]) </p>
 
<table>
<tr><th>%result</th>
<td>A numeric variable that contains:
<ul>
<ul>
<li>string represents the string to be verified. string must be one of:</li>
<li>1, for a true condition.</li>
</li>
<li>0, for a false condition if one of these occurs:
</ul>
<p>A literal enclosed in quotation marks</p>
<ul>
<ul>
<li>%variable.</li>
<li><var class="term">string</var> contains digits, spaces, or punctuation marks</li>
</li>
<li><var class="term">string</var> is null</li>
<li>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.</li>
<li>U.S. English characters in the string have accent marks</li>
</li>
</ul></li>
</ul>
</ul></td></tr>
<p><var>The optional language</var> argument specifies the language to use. The language argument is handled as follows:</p>
 
<tr><th>string</th>
<td>The string to be verified. <var class="term">string</var> must be one of the following:
<ul>
<ul>
<li>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 in the Rocket <var class="product">Model&nbsp;204</var> Parameter and Command Reference Manual for the valid values.</li>
<li>A literal enclosed in quotation marks</li>
<li>A [[Using variables and values in_computation|%variable]]</li>
<li>A field name without quotation marks. In this case, the function call must be embedded in a <var>[[Record_loops#FOR_EACH_RECORD_statement|FOR EACH RECORD]]</var> loop where the current value of the field is verified.</li>
</ul></td></tr>
 
<tr><th>language</th>
<td>An optional string that specifies the language to use. <var class="term">language</var> is handled as follows:
<ul>
<li>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 <var>[[LANGUSER parameter|LANGUSER]]</var> parameter for the valid values.
<p class="code">M204.2340: INVALID LANGUAGE ARGUMENT: 'language' FOR $FUNCTION: ALPHA  
<p class="code">M204.2340: INVALID LANGUAGE ARGUMENT: 'language' FOR $FUNCTION: ALPHA  
</p></li>
</p></li>
<li>When<var> you omit the language</var> argument, <var class="product">Model&nbsp;204</var> performs the validation in U.S. English, even if the value of the LANGUSER parameter is not US, and lowercase characters are not recognized.</li>
 
</li>
<li>If you omit the <var class="term">language</var> argument, <var class="product">Model&nbsp;204</var> performs the validation in U.S. English, even if the value of the <var>LANGUSER</var> parameter is not <code>US</code>, and lowercase characters are not recognized.</li>
<li>An asterisk enclosed in quotation marks ('*') instructs <var class="product">Model&nbsp;204</var> to use the value of the LANGUSER parameter. </li>
 
</li>
<li>An asterisk enclosed in quotation marks (<tt>'*'</tt>) instructs <var class="product">Model&nbsp;204</var> to use the value of the <var>LANGUSER</var> parameter. </li>
</ul>
</ul></td></tr>
<b>Examples</b>
</table>
<p>The following table has examples of the pattern and language arguments as literals:</p>
 
==Examples==
<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 35: Line 50:
<tr>
<tr>
<td>
<td>
<p class="code"><var>$ALPHA('JOHN','US')</var>
<p class="codeInTable">$alpha('JOHN','US')</p></td>
</p></td>
<td align="right"><p>1</p></td></tr>
<td align="right"><var>1</var></td>
 
</tr>
<tr><td><p class="codeInTable">$alpha('M&Acirc;CON','FRENCHC')</p></td>
<tr>
<td align="right"><p>1</p></td></tr>
<td>
 
<p class="code"><var>$ALPHA('M�CON','FRENCHC')</var>
<tr><td><p class="codeInTable">$alpha('M&Acirc;CON','US')</p></td>
</p></td>
<td align="right"><p>0</p></td></tr>
<td align="right"><var>1</var></td>
 
</tr>
<tr><td><p class="codeInTable">$alpha('JOHN SMITH','US')</p></td>
<tr>
<td align="right"><p>0</p></td></tr>
<td>
 
<p class="code">$ALPHA('<var>M�CON','US')</var>
<tr><td><p class="codeInTable">$alpha('&Icirc;LE D'ORL&Eacute;ANS','FRENCHC')</p></td>
</p></td>
<td align="right"><p>0</p></td></tr>
<td align="right">0</td>
 
</tr>
<tr><td><p class="codeInTable">$alpha('12A','US')</p></td>
<tr>
<td align="right"><p>0</p></td></tr>
<td>
 
<p class="code"><var>$ALPHA('JOHN SMITH','US')</var>
<tr><td><p class="codeInTable">$alpha('12A','FRENCHC')</p></td>
</p></td>
<td align="right"><p>0</p></td></tr>
<td align="right"><var>0</var></td>
</tr>
<tr>
<td>
<p class="code"><var>$ALPHA('�LE D'ORL�ANS','FRENCHC')</var>
</p></td>
<td align="right"><var>0</var></td>
</tr>
<tr>
<td>
<p class="code"><var>$ALPHA('12A','US')</var>
</p></td>
<td align="right"><var>0</var></td>
</tr>
<tr>
<td>
<p class="code"><var>$ALPHA('12A','FRENCHC')</var>
</p></td>
<td align="right"><var>0</var></td>
</tr>
</table>
</table>
<p>The following request sorts and prints the names of agents whose name contains non alphabetic characters. The quoted asterisk in the $ALPHA call causes <var class="product">Model&nbsp;204</var> to verify the contents of the field AGENT against whatever language is indicated by the value of the LANGUSER parameter:</p>
<p>
<p class="code">BEGIN
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">RESET LANGUSER 'FRENCHC'
BEGIN
POL.HOLDERS:  FIND ALL RECORDS FOR WHICH
POL.HOLDERS:  FIND ALL RECORDS FOR WHICH
                 RECTYPE = POLICYHOLDER
                 RECTYPE = POLICYHOLDER
               END FIND
               END FIND
               FOR EACH RECORD IN POL.HOLDERS
               FOR EACH RECORD IN POL.HOLDERS
                 IF NOT $ALPHA (AGENT, '*') THEN
                 IF NOT $alpha (AGENT, '*') THEN
                     PLACE RECORD ON LIST BADNAME
                     PLACE RECORD ON LIST BADNAME
                 END IF
                 END IF
Line 92: Line 89:
END   
END   
</p>
</p>
<p class="note"><b>Note:</b> For upward compatibility reasons, $ALPHA and $ALPHNUM do not recognize lowercase English letters as alphabetic characters unless a non-null language parameter is specified.</p>
<p class="note"><b>Note:</b> For upward compatibility reasons, <var>$Alpha</var> and <var>$Alphnum</var> do not recognize lowercase English letters as alphabetic characters unless a non-null language parameter is specified.</p>
 
[[Category:SOUL $functions]]
[[Category:SOUL $functions]]

Latest revision as of 20:04, 8 January 2018

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

Syntax

%result = $Alpha(string [,language])

%result A numeric variable that contains:
  • 1, for a true condition.
  • 0, for a false condition if one of these occurs:
    • string contains digits, spaces, or punctuation marks
    • string is null
    • U.S. English characters in the string have accent marks
string The string to be verified. 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.
language An optional string that specifies the language to use. language 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.