| United States-English |
|
|
|
![]() |
SORT-MERGE/XL Programmer's Guide: 900 Series HP 3000 Computer Systems > Chapter 2 Creating Core Routines That Sort and MergeInitializing a Sort or Merge |
|
You must specify the following to initialize the SORT-MERGE/XL utility and start the sorting or merging process:
The HPSORTINIT intrinsic passes the information necessary to initialize the sorting process, and HPMERGEINIT passes the information to initialize the merging process. The syntax for HPSORTINIT and HPMERGEINIT is:
The core routine examples that follow do not use all of the parameters listed above. When you enter these intrinsics, you must maintain the position of any unused parameters with commas. The inputfiles and outputfiles parameters in this chapter are files; input and output by record is discussed in Chapter 3. The altseq and charseq parameters, which alter the collating sequence, are discussed in Chapter 4. The statistics parameters, which get SORT-MERGE/XL information, are discussed in Chapter 5 The most common way to supply information to SORT-MERGE/XL is through an input file. Input considerations include:
SORT-MERGE/XL accepts one or more input files. You create these files with an editor, in a program, or from a database. You may not use $NULL as an input file. Remember that your data items must be in a fixed format. Each data item of the same type must start in the same column. If your data is not in a fixed format, your results will be unpredictable. You can use any text editor to create fixed format data files stored in character format. For example, EDIT/3000 keeps your data items lined up by using tabs to separate them. This ensures a fixed format. To follow the example below, enter EDIT/3000, set the tab character to a displayable character, and indicate where you want the tabs to be set.
To verify that the tab character and the tabs are set the way you want them, enter:
You will see EDIT/3000 display:
Enter your information in the following manner:
When you list this file, it will appear as follows:
Give your file a meaningful name, save it with the KEEP command. This example file contains permanent employee information, so it is kept as PERMEMP. For more information about EDIT/3000, refer to the EDIT/3000 Reference Manual. With intrinsics, you can access SORT-MERGE/XL programmatically from any language. When you create a file from a program, the data can be any data type allowed by the language you are using. For information about creating input files and saving the output file, refer to the programmer's guide for your language, such as:
When programming in COBOL, you can sort and merge records directly through the COBOL SORT and MERGE statements. These statements allow you to specify the key, collating sequence, and file or record output to be used by the SORT-MERGE/XL utility. For further information, refer to COBOL II Reference Manual and COBOL II/XL Reference Manual Supplement. You will find FORTRAN information in Appendix D of this manual. The SORT and MERGE intrinsics access input files through their file numbers. You pass the identification numbers in the inputfiles parameter of the HPSORTINIT or HPMERGEINIT intrinsic. The inputfiles parameter is an array. The last number in the array must be zero, as shown in the example below. To get the file identification numbers, open the input files with the intrinsic HPFOPEN (or FOPEN), as in the example. The following is from the example at the end of the chapter. The first part opens the files TEMPEMP and PERMEMP, and gets their file numbers, (tempFileNum and permFileNum). The second part puts these identification numbers in an array for the inputfiles parameter of the HPSORTINIT or HPMERGEINIT intrinsics.
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. 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. The most common method of maintaining output from SORT-MERGE/XL is by specifying an output file. Output considerations include:
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 HPSORTINIT or HPMERGEINIT intrinsics.
Now that you have the file numbers, you can initialize the inputfiles parameter:
If you do not specify anything in outputfile SORT-MERGE/XL assumes that output will be by individual record and that you are using the HPSORTOUTPUT intrinsic. You specify the content of the SORT/XL output file with the outputoption parameter of HPSORTINIT. The part of the core routine example at the end of the chapter that specifys the outputoption in HPSORTINIT is:
The options are outputoption equals:
You specify the format of the MERGE/XL output file with the keysonly parameter of HPMERGEINIT. The part of the core routine example at the end of the chapter that specifys the keysonly in HPSORTINIT is:
The options are keysonly equals:
The key indicates the part of each record that is compared to determine output record order. In HPSORTINIT or HPMERGEINIT, you indicate the number of keys with the numkeys parameter and give key information in the keys parameter. The part of the core routine example at the end of the chapter that specifies keys is:
The keys parameter is an integer array; each key contains four elements you specify. The elements are:
If your key is a character or byte data type, you may use the altseq parameter to specify two things.
The altseq parameter is an array with two parts. The first element of the array is defined by the following table.
The second element of altseq specifies the number of characters in the collating sequence. Remember that SORT-MERGE/XL begins counting on zero, and so you subtract one from the ordinary counting number. For example, ASCII has 256 characters, so the example below specifies the value 255. The example at the end of this chapter uses ASCII input and ASCII sequence. The following is the part of the example that specifies the input data type and sorting sequence.
The altseq parameter is used only for byte data types The most common are ASCII and EBCDIC. Refer to Chapter 4 for information about alternate collating sequences, like one you design yourself or one of the predefined Native Language types. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||