$AlphNum: Difference between revisions
m (misc cleanup) |
No edit summary |
||
Line 1: | Line 1: | ||
<p> | <p> | ||
The <var>$AlphNum</var> function verifies whether a string is composed only of characters | 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. | ||
<ul> | |||
<li>1 is returned for a true condition.</li> | |||
<li>0 is returned for a false condition if there are any spaces or punctuation marks in the string, or if the string is null.</li> | |||
</ul></p> | |||
==Syntax== | ==Syntax== | ||
Line 16: | Line 20: | ||
<li>A field name that is not enclosed in 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 that is not enclosed in 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> | ||
<li>The optional <var class="term">language</var> argument specifies the language to use. The language argument is handled as follows: | <li>The optional <var class="term">language</var> argument specifies the language to use. The language argument is handled as follows: | ||
<ul> | <ul> | ||
<li>If the <var class="term">language</var> argument is omitted, <var class="product">Model 204</var> performs the validation in U.S. English | <li>If the <var class="term">language</var> argument is omitted, <var class="product">Model 204</var> performs the validation in U.S. English (even if the value of the <var>LANGUSER</var> parameter is not US) and lowercase characters are not recognized.</li> | ||
<li>An asterisk enclosed in quotation marks (<tt>'*'</tt>) instructs <var class="product">Model 204</var> to use the value of the <var>LANGUSER</var> parameter. | <li>An asterisk enclosed in quotation marks (<tt>'*'</tt>) instructs <var class="product">Model 204</var> to use the value of the <var>LANGUSER</var> parameter. | ||
Line 26: | Line 29: | ||
<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 <var>[[LANGUSER parameter|LANGUSER]]</var> parameter for the valid values.</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 <var>[[LANGUSER parameter|LANGUSER]]</var> parameter for the valid values.</li> | ||
</ul> | |||
</li> | |||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
<p> | <p> | ||
The following example illustrates the string and language arguments as literals enclosed in quotation marks:</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"> |
Revision as of 22:22, 3 March 2016
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.
- 1 is returned for a true condition.
- 0 is returned for a false condition if there are any spaces or punctuation marks in the string, or if the string is null.
Syntax
$AlphNum(string[,language])
Where:
- The string argument represents the characters to verify, which must be one of the following:
- A string of characters 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.
- The optional language argument specifies the language to use. The language argument is handled as follows:
- If the language argument is omitted, 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.
- 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 for the valid values.
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.