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

Chapter 2 35
Creating Core Routines That Sort and Merge
Example of Core Sorting Routine
Example 2-1. SORTFILE Program
program SORTFILE (input,output);
{This program reads the files, TEMPEMP and PERMEMP, }
{sorts by last name, and outputs to the file, ALLEMP}
var
tempFileNum: INTEGER;
permFileNum: INTEGER;
outFileNum : INTEGER;
status : INTEGER;
procedure HPFOPEN ; intrinsic;
procedure HPSORTINIT; intrinsic;
procedure HPSORTERRORMESS; intrinsic;
procedure HPSORTEND; intrinsic;
procedure FCLOSE; intrinsic;
procedure OPEN_FILES;
const
designator = 2;
domain = 3;
access = 11;
record_size = 19;
var
tempFile : packed array [1..10] of CHAR;
permFile : packed array [1..10] of CHAR;
outFile : packed array [1..10] of CHAR;
permanent : INTEGER;
new : INTEGER;
write : INTEGER;
size : INTEGER;
begin
tempFile := '%TEMPEMP%';
permanent := 1;
HPFOPEN (tempFileNum, status, designator, tempFile, domain, permanent)
;
permFile := '%PERMEMP%';
HPFOPEN (permFileNum, status, designator, permFile, domain, permanent)
; new := 4;
write := 1;
size := 80;
outFile := '%ALLEMP%';
HPFOPEN (outFileNum, status, designator, outFile, domain, new, access,
write, record_size, size);
end;