The function sort_text_array_characters sorts the elements of a text array and stores the sorted elements in a second array.
sort_text_array_characters ( input;output;number of elements to sort )
The function sort_text_array_characters is of type BOOL, and has three parameters:
The function sort_text_array_characters will return TRUE if the array was sorted successfully, and FALSE in one of the following cases:
sort_text_array_characters fails the output array is unmodified. function sort_text_array_characters will perform a culture-neutral alphabetical sort on the text elements using Unicode codepoints. Any word processor instructions in the text elements are included in the sort, and sort before regular characters.
Example
ARRAY TEXT input [4]
ARRAY TEXT output[4]
NUMBER i
ASSIGN input[1] := "c"
ASSIGN input[2] := "d"
ASSIGN input[3] := "a"
ASSIGN input[4] := "b"
IF sort_text_array_characters (input; output; 4) THEN
FOR i FROM 1 UPTO 4
DO
#
@(i) @(output[i])
#
OD
ELSE
#
Failed to sort the input.
#
STOP
FI
Here the fact that the sort_text_array_characters is a function of type BOOL is used to implement error handling. If the sort succeeds the return value of the function will be TRUE, the IF statement becomes TRUE, and the THEN part is executed. If the return is FALSE the ELSE part of the IF statement is executed.