$LangSrt: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
m (Mlarocca moved page $LANGSRT to $LangSrt: Lower case change)
(No difference)

Revision as of 19:43, 21 July 2014

$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 User Language 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:

  • When 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 in the Rocket Model 204 Parameter and Command Reference Manual for the valid values.

Note: The $LANGSRT function returns the string unchanged when 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