$LangSrt: Difference between revisions
m (misc cleanup) |
|||
Line 1: | Line 1: | ||
<p>$ | <p> | ||
<p>By determining whether one string is greater or less than another string, you can use the $ | <var>$LangSrt</var> translates a given string according to the specified language into a language-neutral binary string against which you can sort.</p> | ||
<p> | |||
<p class=" | By determining whether one string is greater or less than another string, you can use the <var>$LangSrt</var> function to compare two strings. First apply the <var>$LangSrt</var> function to the strings and then compare them using the SOUL greater-than (<var>GT</var>) and less-than-or-equal-to (<var>LT</var>) operators.</p> | ||
==Syntax== | |||
<p class="syntax">$LangSrt('<span class="term">string</span>'[,<span class="term">language</span>]) | |||
</p> | </p> | ||
< | <p> | ||
Where:</p> | |||
<ul> | <ul> | ||
<li> | <li>The <var class="term">string</var> argument is a literal enclosed in quotation marks or a %variable containing the original data to be translated into collating sequence.</li> | ||
<li>An asterisk enclosed in quotation marks ('*') instructs <var class="product">Model 204</var> to use the value of the LANGUSER parameter.</li> | <li>The optional <var class="term">language</var> argument is the name of one of the defined languages, which specifies which collating sequence to use. The language argument is handled as follows: | ||
<ul> | |||
<li>You can enter the name of a valid language enclosed in quotation marks or a %variable containing a valid language. If you enter value that is not supported, the request is canceled with an error message. See | <li>If you omit the <var class="term">language</var> argument, <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> | |||
<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> | |||
<li>You can enter the name of a valid language enclosed in quotation marks or a %variable containing a valid language. If you enter value that 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> | ||
<p class="note"><b>Note:</b> The $ | |||
<p class="note"><b>Note:</b> The <var>$LangSrt</var> function returns the string unchanged if the language is U.S. English. </p> | |||
<p>The following procedure stores the value of NAME from each record into array %STR. The $ | |||
==Example== | |||
<p> | |||
The following procedure stores the value of <code>NAME</code> from each record into array <code>%STR</code>. The <var>$LangSrt</var> function translates each value of <code>NAME</code> into a language-specific collating sequence and stores the value into the array <code>%SORTSTR</code>. The procedure then calls a user-written subroutine, <code>MYSORT</code>, that sorts the <code>%SORTSTR</code> array in ascending order. At this point the procedure invokes the <var>$LangSrt</var> function to translate the collating string back to its original form and prints the names in language-specific order.</p> | |||
<p class="code">BEGIN | <p class="code">BEGIN | ||
DECLARE SUBROUTINE MYSORT (STRING LEN 20 ARRAY(*)) | DECLARE SUBROUTINE MYSORT (STRING LEN 20 ARRAY(*)) | ||
Line 44: | Line 53: | ||
END | END | ||
</p> | </p> | ||
[[Category:SOUL $functions]] | [[Category:SOUL $functions]] |
Revision as of 20:11, 9 March 2015
$LangSrt translates a given string according to the specified language into a language-neutral binary string against which you can sort.
By determining whether one string is greater or less than another string, you can use the $LangSrt function to compare two strings. First apply the $LangSrt function to the strings and then compare them using the SOUL greater-than (GT) and less-than-or-equal-to (LT) operators.
Syntax
$LangSrt('string'[,language])
Where:
- The string argument is a literal enclosed in quotation marks or a %variable containing the original data to be translated into collating sequence.
- The optional language argument is the name of one of the defined languages, which specifies which collating sequence to use. The language argument is handled as follows:
- 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.
- You can enter the name of a valid language enclosed in quotation marks or a %variable containing a valid language. If you enter value that is not supported, the request is canceled with an error message. See the LANGUSER parameter for the valid values.
Note: The $LangSrt function returns the string unchanged if the language is U.S. English.
Example
The following procedure stores the value of NAME
from each record into array %STR
. The $LangSrt function translates each value of NAME
into a language-specific collating sequence and stores the value into the array %SORTSTR
. The procedure then calls a user-written subroutine, MYSORT
, that sorts the %SORTSTR
array in ascending order. At this point the procedure invokes the $LangSrt function to translate the collating string back to its original form and prints the names in language-specific order.
BEGIN DECLARE SUBROUTINE MYSORT (STRING LEN 20 ARRAY(*)) %STR STRING LEN 20 ARRAY (20) NO FS %SORTSTR STRING LEN 20 ARRAY (20) * FD1: IN DATA FIND ALL RECORDS END FIND %I = 1 FOR EACH RECORD IN FD1 %STR(%I) = NAME %I = %I + 1 END FOR FOR %J FROM 1 TO %I-1 %SORTSTR(%J) = $LANGSRT(%STR(%J),'TURKISH') END FOR * * SORT NAMES * CALL MYSORT(%SORTSTR) * FOR %J FROM 1 TO %I-1 %STR(%J) = $LANGUST(%SORTSTR(%J),'TURKISH') PRINT %STR(%J) END FOR END