SORT-MERGE/XL Programmer's Guide (32650-90884)

54 Chapter4
Altering the Collating Sequence
Example of Using an Altered Sequence
Example of Using an Altered Sequence
The following example sorts the data file DATA. The entries in DATA are sorted using an
altered collating sequence that is explicitly specified in the program. The sequence
contains all displayable ASCII characters and alters the order of the alphabetic characters
to AaBbCc ....The output file is called FRUIT.
DATA - a file of fruit names
banana
Apple
Grapes
grapes
Pear
peach
orange
Example 4-1. SORTALT Program
program SORTALT (input,output);
{This program reads the file DATA, sorts by fruit name, }
{outputs to the file FRUIT, and uses an altered sequence.}
var
dataFileNum : INTEGER;
fruitFileNum: INTEGER;
status : INTEGER;
procedure HPFOPEN ; intrinsic;
procedure HPSORTINIT; intrinsic;
procedure HPSORTEND; intrinsic;
procedure FCLOSE; intrinsic;
procedure OPEN_FILES;
const
designator = 2;
domain = 3;
access = 11;
record_Size = 19;
var
datafile : packed array [1..10] of CHAR;
fruitfile : packed array [1..10] of CHAR;
permanent : INTEGER;
new : INTEGER;
write : INTEGER;
size : INTEGER;