SORT-MERGE/XL Programmer's Guide (32650-90884)
Chapter 3 47
Input and Output by Record
Example of Record Output
Example of Record Output
The following program sorts the personnel files, TEMPEMP and PERMEMP, that were
also used for the last example. They are sorted by last name. The output records are
altered before they are sent to $STDLIST.
Example 3-2. SORTREC_OUT Program
program SORTREC_OUT (input,output);
{This program reads data from the TEMPEMP and PERMEMP files, sorts them by last
{name, outputs them by record, alters the output record, and prints the record to
($STDLIST.}
var
tempFileNum: INTEGER;
permFileNum: INTEGER;
status : INTEGER;
procedure HPFOPEN ; intrinsic;
procedure HPSORTINIT; intrinsic;
procedure HPSORTOUTPUT; intrinsic;
procedure HPSORTEND; intrinsic;
procedure FCLOSE; intrinsic;
procedure OPEN_FILES;
const
designator = 2;
domain = 3;
access = 11;
var
tempfile : packed array [1..10] of CHAR;
permfile : packed array [1..10] of CHAR;
permanent : INTEGER;
begin
tempfile := '%TEMPEMP%';
permanent := 1;
HPFOPEN (tempFileNum, status, designator, tempfile, domain, permanent);
permfile := '%PERMEMP%';
HPFOPEN (permFileNum, status, designator, permfile, domain, permanent);
end;
procedure DO_SORT;
var
inputfiles : array [1..3] 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;