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

48 Chapter3
Input and Output by Record
Example of Record Output
buffer : packed array [1..80] of CHAR;
begin
inputfiles [1] := tempFileNum;
inputfiles [2] := permFileNum;
inputfiles [3] := 0;
outputOption := 0; {output record format same as input record format}
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}
HPSORTINIT (status, inputfiles,, outputOption,,,
numKeys, keys, altseq,,,,,);
repeat {get output record and alter it}
HPSORTOUTPUT (status, buffer, length);
strmove (7, 'Empl. #',1, buffer, 33);
strmove (10, 'Hire Date:', 1, buffer, 50);
if length >0 then
writeln (buffer);
until length <0;
HPSORTEND (status, );
end;
procedure CLOSE_FILES;
var
disposition : SHORTINT;
securityCode : SHORTINT;
begin
disposition := 0;
securityCode := 0;
FCLOSE (tempFileNum, disposition, securityCode);
FCLOSE (permFileNum, disposition, securityCode);
end;
begin {main}
OPEN_FILES;
DO_SORT;
CLOSE_FILES;
end.
When this program is executed, the output is written to the screen:
Everett, Joyce Empl. # 000029 Hire Date: 10/19/87
Gangley, Tomas Empl. # 000003 Hire Date: 06/06/87
Jackson, Jonathan Empl. # 000006 Hire Date: 06/06/87
Jackson, Rosa Empl. # 000022 Hire Date: 08/15/87