SORT-MERGE/XL Programmer's Guide (32650-90884)
22 Chapter2
Creating Core Routines That Sort and Merge
Initializing a Sort or Merge
Now that you have the file numbers, you can initialize the
inputfiles
parameter:
If you do not specify anything in
inputfiles
in HPSORTINIT, SORT/XL assumes that input
will be by individual record and that you are using the HPSORTINPUT intrinsic. For
information about input by record, refer to Chapter 3.
Using Tape Input (SORT/XL Only)
If any of your files are stored on tape, HPSORTINIT needs to know the total number of
records that you have on disc and tape. This is specified in the
numrecs
parameter. If you
have tape files but do not specify this parameter, SORT/XL defaults to 10,000 records per
tape file. SORT/XL takes the size of your disc files from the file label; if all your files are on
disc, do not specify this parameter.
Specifying Output
The most common method of maintaining output from SORT-MERGE/XL is by specifying
an output file. Output considerations include:
• Creating the Output File.
• Output Record Format (SORT/XL).
• Output Record Format (MERGE/XL).
Creating the Output File
You specify the output file by indicating its file identification number in the
outputfile
parameter in HPSORTINIT or HPMERGEINIT. The
outputfile
parameter is an array. The
last number in the array must be zero, as shown in the example below.
To get the file number, open the output file with HPFOPEN (or FOPEN), as in the example.
The following is from the example at the end of the chapter. The first part creates a new
permanent file named outFile with WRITE access and with logical records of 80 bytes. The
second part puts the number of this file into an array for the
outputfile
parameter of the
var
inputfiles : array [1..3] of INTEGER;
.
.
.
inputfiles[1] := tempFileNum; {from HPFOPEN}
inputfiles[2] := permFileNum: {from HPFOPEN}
inputfiles[3] := 0; {last is always zero}