$LangSrt: Difference between revisions
m (misc cleanup) |
No edit summary |
||
Line 1: | Line 1: | ||
<p> | <p> | ||
<var>$LangSrt</var> translates a given string according to the specified language into a language-neutral | <var>$LangSrt</var> translates a given string according to the specified language into a language-neutral hexadecimal string against which you can sort. A printout or display of the returned value will be the character representation based on the language argument.</p> | ||
<p> | <p> | ||
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> | 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> | ||
Line 10: | Line 10: | ||
Where:</p> | Where:</p> | ||
<ul> | <ul> | ||
<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>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 a collating sequence.</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: | <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 <var class="term">language</var> argument is handled as follows: | ||
<ul> | <ul> | ||
<li>If you omit the <var class="term">language</var> argument, <var class="product">Model 204</var> performs the validation in U.S. English | <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>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>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> | ||
Line 26: | Line 26: | ||
==Example== | ==Example== | ||
<p> | <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 < | 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>.</p> | ||
<p>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 <code>$LangUst</code> 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 51: | Line 52: | ||
PRINT %STR(%J) | PRINT %STR(%J) | ||
END FOR | END FOR | ||
END | END</p> | ||
</p> | |||
[[Category:SOUL $functions]] | [[Category:SOUL $functions]] |
Latest revision as of 22:44, 8 March 2016
$LangSrt translates a given string according to the specified language into a language-neutral hexadecimal string against which you can sort. A printout or display of the returned value will be the character representation based on the language argument.
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 a 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 $LangUst
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