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

Chapter 2 39
Creating Core Routines That Sort and Merge
Example of Core Merging Routine
size := 80;
outFile := '%ALLEMP%';
HPFOPEN (oOutFileNum, status, designator, outFile, domain, new, access,
write, record_size, size);
end;
procedure DO_MERGE;
var
inputfiles : array [1..3] of INTEGER;
outputfile : array [1..2] of INTEGER;
keysonly : INTEGER;
numKeys : INTEGER;
keys : array [1..4] of INTEGER;
altseq : packed array [1..2] of CHAR;
message : packed array [1..80] of CHAR;
length : INTEGER;
begin
inputfiles [1] := tempFileNum;
inputfiles [2] := permFileNum;
inputfiles [3] := 0;
outputfile [1] := outFileNum; {from HPFOPEN}
outputfile [2] := 0;
keysonly := 0; {output record format same as input record format }
numKeys := 1; {one key}
keys[1] := 41; {key begins}
keys[2] := 20; {key length}
keys[3] := 0; {byte data}
keys[4] := 0; {ascending order}
altseq[1] := CHR(255); {data = ASCII; sequence = ASCII}
altseq[2] := CHR(255); {256 characters in ASCII}
HPMERGEINIT (status, inputfiles,, outputfile,, keysonly, numKeys, keys,
altseq,,,,,);
if status <> 0 then {if error in HPMERGEINIT }
begin {get message and print it to screen}
message := ' ';
HPMERGEERRORMESS (status, message, length);
writeln (Message);
end;
HPMERGEEND (status, statistics);
if status <> 0 then {if error in HPMERGEEND }
begin {get message and print it to screen}
message := ' ';
HPMERGEERRORMESS (status, message, length);
writeln (message)
end;
end;