$AlphNum: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Mlarocca moved page $Alphnum to $AlphNum: Change N to upper case)
m (add italics)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<p>The $Alphnum function verifies whether a string is composed only of characters which are valid in the specified (or default) language, and digits 0 through 9. 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>$AlphNum</var> function verifies whether a string is composed only of characters that are valid in the specified (or default) language, and digits 0 through 9. </p>
<p class="code">$Alphnum(<var class="term">string</var>[,<var class="term">language</var>])
 
==Syntax==
<p class="syntax"><span class="term">%result</span> = $AlphNum(<span class="term">string</span>[,<span class="term">language</span>])
</p>
</p>
<p>where:</p>
 
<p><var>The string</var> argument represents the characters to verify, which must be one of the following:</p>
<table>
<tr><th>%result</th>
<td>A numeric variable that contains:
<ul>
<ul>
<li>A string of characters enclosed in quotation marks.</li>
<li>1, for a true condition.</li>
</li>
<li>0, for a false condition if one of these occurs:
<li>A %variable.</li>
<ul>
</li>
<li><var class="term">string</var> contains spaces or punctuation marks</li>
<li>A field name that is not enclosed in 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><var class="term">string</var> is null</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>
<li>A literal enclosed in quotation marks</li>
<li>A [[Using_variables_and_values_in_computation|%variable]]</li>
<li>A field name that is not enclosed in 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>
<ul>
<li>When the <var class="term">language</var> argument is omitted, <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>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 an error message. See the <var>[[LANGUSER parameter|LANGUSER]]</var> parameter for the valid values.
</li>
</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>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>You can enter the name of a valid language enclosed in quotation marks or a %variable containing a valid language. If the value you enter is not supported, the request is canceled with an 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>
<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 example illustrates the string and language arguments as literals enclosed in quotation marks:</p>
 
==Examples==
<p>
The following example illustrates the <var class="term">string</var> and <var class="term">language</var> arguments as literals enclosed in quotation marks:</p>
<table>
<table>
<tr class="head">
<tr class="head">
Line 29: Line 46:
<th>Returns...</th>
<th>Returns...</th>
</tr>
</tr>
<tr>
<tr>
<td>
<td>
<p class="code"><var>$alphnum ('JOHN','US')</var>
<p class="codeInTable">$alphnum ('JOHN','US')
</p></td>
</p></td>
<td align="right"><var>1</var></td>
<td align="right"><p>1</p></td>
</tr>
</tr>
<tr>
<tr>
<td>
<td>
<p class="code"><var>$alphnum ('M�CON','FRENCHC')</var>
<p class="codeInTable">$alphnum ('MÂCON','FRENCHC')
</p></td>
</p></td>
<td align="right"><var>1</var></td>
<td align="right"><p>1</p></td>
</tr>
</tr>
<tr>
<tr>
<td>
<td>
<p class="code"><var>$alphnum ('M�CON','US')</var>
<p class="codeInTable">$alphnum ('MÂCON','US')
</p></td>
</p></td>
<td align="right">0</td>
<td align="right"><p>0</p></td>
</tr>
</tr>
<tr>
<tr>
<td>
<td>
<p class="code"><var>$alphnum ('JOHN SMITH','US')</var>
<p class="codeInTable">$alphnum ('JOHN SMITH','US')
</p></td>
</p></td>
<td align="right"><var>0</var></td>
<td align="right"><p>0</p></td>
</tr>
</tr>
<tr>
<tr>
<td>
<td>
<p class="code"><var>$alphnum ('�LE D'ORL�ANS','FRENCHC')</var>
<p class="codeInTable">$alphnum ('ÎLE D'ORLÉANS','FRENCHC')
</p></td>
</p></td>
<td align="right"><var>0</var></td>
<td align="right"><p>0</p></td>
</tr>
</tr>
<tr>
<tr>
<td>
<td>
<p class="code"><var>$alphnum ('12A','US')</var>
<p class="codeInTable">$alphnum ('12A','US')
</p></td>
</p></td>
<td align="right"><var>1</var></td>
<td align="right"><p>1</p></td>
</tr>
</tr>
<tr>
<tr>
<td>
<td>
<p class="code"><var>$alphnum ('12A','FRENCHC')</var>
<p class="codeInTable">$alphnum ('12A','FRENCHC')
</p></td>
</p></td>
<td align="right"><var>1</var></td>
<td align="right"><p>1</p></td>
</tr>
</tr>
</table>
</table>
<p>In the following example, the request sorts by name and processes records whose designated field value does not meet the $Alphnum criteria. The second argument in the $Alphnum call instructs <var class="product">Model&nbsp;204</var> to use French Canadian to perform the validation:</p>
<p>
In the following example, the request sorts by name and processes records whose designated field value does not meet the <var>$AlphNum</var> criteria. The second argument in the <var>$AlphNum</var> call instructs <var class="product">Model&nbsp;204</var> to use French Canadian to perform the validation:</p>
<p class="code">BEGIN
<p class="code">BEGIN
           %SEARCH = $READ('ENTER FIELD NAME')
           %SEARCH = $READ('ENTER FIELD NAME')
Line 86: Line 111:
   SORT.RECS: SORT RECORDS ON LIST BAD BY FULLNAME
   SORT.RECS: SORT RECORDS ON LIST BAD BY FULLNAME
           FOR EACH RECORD IN SORT.RECS
           FOR EACH RECORD IN SORT.RECS
               .
               . . .
              .
              .
   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|$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:07, 8 January 2018

The $AlphNum function verifies whether a string is composed only of characters that are valid in the specified (or default) language, and digits 0 through 9.

Syntax

%result = $AlphNum(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 spaces or punctuation marks
    • string is null
string The string to be verified. string must be one of the following:
  • A literal enclosed in quotation marks
  • A %variable
  • A field name that is not enclosed in 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 an error message. See the LANGUSER parameter for the valid values.
  • 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 example illustrates the string and language arguments as literals enclosed in quotation marks:

Function code... Returns...

$alphnum ('JOHN','US')

1

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

1

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

0

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

0

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

0

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

1

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

1

In the following example, the request sorts by name and processes records whose designated field value does not meet the $AlphNum criteria. The second argument in the $AlphNum call instructs Model 204 to use French Canadian to perform the validation:

BEGIN %SEARCH = $READ('ENTER FIELD NAME') FIND.RECS: FIND ALL RECORDS FOR WHICH RECTYPE = POLICYHOLDER END FIND PLACE RECORDS IN FIND.RECS ON LIST BAD FOR EACH RECORD IN FIND.RECS IF $alphnum(%%SEARCH,'FRENCHC') THEN REMOVE RECORD FROM LIST BAD END IF END FOR SORT.RECS: SORT RECORDS ON LIST BAD BY FULLNAME FOR EACH RECORD IN SORT.RECS . . . 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.