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

44 Chapter3
Input and Output by Record
Example of Record Input
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);
procedure DO_SORT;
var
outputfile : array [1..2] of INTEGER;
outputOption : 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;
lngth : SHORTINT;
buffer : packed array [1..80] of CHAR;
recLength : INTEGER;
begin
outputfile [1] := outFileNum; {From HPFOPEN}
outputfile [2] := 0;
outputOption := 0; {output record format same as input record format }
recLength := 80; {maximum record length}
numKeys := 1; {one key}
keys[1] := 1; {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}
end;
HPSORTINIT (status,, outputfile, outputOption,