$LangSrt: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Mlarocca moved page $LANGSRT to $LangSrt: Lower case change)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<p>$LANGSRT translates a given string according to the specified language into a language-neutral binary string against which you can sort.</p>
<p>
<p>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 User Language greater-than (GT) and less-than-or-equal-to (LT) operators.</p>
<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>
<b>Syntax</b>
<p>
<p class="code">$LANGSRT('<var class="term">string</var>'[,<var class="term">language</var>])
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>
<p>
<p><var>The string</var> argument is a literal enclosed in quotation marks or a %variable containing the original data to be translated into collating sequence.</p>
Where:</p>
<p><var>The optional 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:</p>
<ul>
<ul>
<li>When 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 LANGUSER parameter is not US, and lowercase characters are not recognized.</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>
 
<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>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:
</li>
<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 The LANGUSER parameter in the Rocket <var class="product">Model&nbsp;204</var> Parameter and Command Reference Manual for the valid values.</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 US) and lowercase characters are not recognized.</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>
 
<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 $LANGSRT function returns the string unchanged when the language is U.S. English. </p>
 
<b>Example</b>
<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 $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.</p>
 
==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>.</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 42: 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