User Exit for Computation of Sort Keys - NATUSKnn

Some national languages contain characters which are not sorted in the correct alphabetical order by a sort program or database system. With the system function SORTKEY you can convert such "incorrectly sorted" characters into other characters that are "correctly sorted" alphabetically.

When you use the SORTKEY function in a Natural program, the user exit NATUSKnn will be invoked - nn being the current language code (that is, the current value of the system variable *LANGUAGE).

You can write a NATUSKnn user exit in the C programming language using the CALL interface. The character-string specified with SORTKEY will be passed to the user exit. The user exit has to be programmed so that it converts "incorrectly sorted" characters in this string into corresponding "correctly sorted" characters. The converted character string is then used in the Natural program for further processing.

Note:
A conversion table is not supplied.

NATUSKnn is called using the CALL interface. The parameters of the C function have the following values:

Parameter Contents
1 The number of arguments.
2 The array of pointers to the operands.
3 The array of field information for each operand.

If you use the Natural system function #OP1=SORTKEY(#OP2), the source operand is in the arrays at index 0 and the target operand (#OP1) is in the arrays at index 1.

A sample user exit, natusk01.c, is provided in source form: it applies to English and converts all English lower-case letters in the character string to upper-case letters. The sample is to be found in $NATDIR/$NATVERS/samples/sysexuex, where you can also find the other user exits.

The source code of the example contains all comments which are needed to write a specific user exit for SORTKEY.

For linkage and loading conventions, refer to the CALL statement.