SORT-MERGE/XL Programmer’s Guide 900 Series HP 3000 Computer Systems Manufacturing Part Number: 32650-90884 E0300 U.S.A.
Notice The information contained in this document is subject to change without notice. Hewlett-Packard makes no warranty of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. Hewlett-Packard shall not be liable for errors contained herein or for direct, indirect, special, incidental or consequential damages in connection with the furnishing or use of this material.
Contents 1. Introduction Processing a Sort or Merge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sorting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Merging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Keys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents Example of Using HPSORTTITLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 A. HPSORT Intrinsic Status Returns B. HPMERGE Intrinsic Status Returns C. ASCII/EBCDIC Table D. FORTRAN Program Examples Example of Core Sorting Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 Example of Core Merging Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figures Figure 1-1.. Flowchart of Intrinsic Order. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Figure 1-2.. SORT/XL Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Figure 1-3.. MERGE/XL Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Figure 1-4.. Key Comparing Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Figure 2-1.. Core Routine . . .
Figures 6
Tables Table C-1.. ASCII/EBCDIC Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Table E-1.. Business BASIC Equivalents of SORT-MERGE/XL Data Types. . . . . . . . . . 122 Table E-2.. HP C XL Equivalents of SORT-MERGE/XL Data Types . . . . . . . . . . . . . . . . 123 Table E-3.. HP COBOL II/XL Equivalents of SORT-MERGE/XL Data Types. . . . . . . . . 124 Table E-4.. HP FORTRAN 77/XL Equivalents of SORT-MERGE/XL Data Types. . . . . . 125 Table E-5..
Tables 8
Preface SORT-MERGE/XL Programmer's Guide is intended for use by experienced programmers who are developing applications that require sorting or merging operations. This Programmer's Series manual explains how to use the SORT-MERGE/XL subsystem and related intrinsics. This manual assumes knowledge of general programming and MPE concepts, but little or no experience with the HPSORT or HPMERGE intrinsics. For current specific information about the intrinsics, the MPE/iX Intrinsics Reference Manual.
1 Introduction This chapter introduces the basic concepts involved in sorting and merging, and provides information about accessing SORT-MERGE/XL programmatically with the sort and merge intrinsics. Topics include: • Processing a Sort or Merge • Sorting • Merging • Keys • Error Checking • Large File Support For information on using SORT-MERGE/XL as a utility, refer to SORT-MERGE/XL General User's Guide.
Introduction Processing a Sort or Merge Processing a Sort or Merge SORT-MERGE/XL is a set of utilities that allows you to sort a group of records or merge several sorted groups of records into one. The output contains records presented in a specified sequence. You may use SORT-MERGE/XL as a utility and call it from the MPE XL command interpreter (CI), or access it programmatically with the sort and merge intrinsics from a program.
Introduction Sorting Sorting When you sort a set of records, you must specify the set of keys by which the records are to be ordered. The format of all records must be the same. These records may be submitted to SORT/XL individually or in one or more files. File input (as shown in Figure 1-2.) is the most common method of input.
Introduction Merging Merging MERGE/XL only merges files that have already been sorted. For example, if you merge a file that contains information on newly hired employees with a file that contains information on current employees, each file must have the same record format and be sorted by the same information. If you merged two such files, each sorted by last name, you would get one output file with all employees sorted by last name.
Introduction Keys Keys When information is sorted or merged, keys determine the output record sequence. Keys are defined by their beginning position, length, key type, and ordering sequence (ascending or descending). For example, to sort by last names with the record format below, you would specify a key that begins in column 1 and is 20 characters long, byte (ASCII) type, and ascending sequence.
Introduction Error Checking For more information about specifying keys, refer to Chapter 2. For more information about collating sequences, refer to Chapter 4. Error Checking Good programming practice specifies that each intrinsic call should be checked to ensure that the call was successful. Each intrinsic contains a status parameter that returns a value indicating the success or failure of the routine. If no error occurred with the intrinsic call, a value of zero (0) is returned in the status parameter.
2 Creating Core Routines That Sort and Merge This chapter describes two sets of operations: a basic sort and a basic merge. The procedure development is described step by step. The complete examples are at the end of the chapter. These core routines use a minimum set of operations to do a simple sort and merge. These examples take input from two files and return output to one file. They use the standard ASCII collating sequence. Other options are discussed in other chapters.
Creating Core Routines That Sort and Merge Structure of the Core Routines Structure of the Core Routines A simple sorting or merging operation can be performed using only three intrinsics and a subset of their parameters. • HPSORTINIT begins the sorting process and HPMERGEINIT begins the merging process. Parameters define what will be passed to the utility. All HPSORTINIT and HPMERGEINIT parameters are optional.
Creating Core Routines That Sort and Merge Initializing a Sort or Merge Initializing a Sort or Merge You must specify the following to initialize the SORT-MERGE/XL utility and start the sorting or merging process: • input file(s) • output file • keys • data type and collating sequence The HPSORTINIT intrinsic passes the information necessary to initialize the sorting process, and HPMERGEINIT passes the information to initialize the merging process.
Creating Core Routines That Sort and Merge Initializing a Sort or Merge Creating Input Files in an Editor 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.
Creating Core Routines That Sort and Merge Initializing a Sort or Merge 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.
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: var inputfiles : array [1..3] of INTEGER; . . . inputfiles[1] := tempFileNum; {from HPFOPEN} inputfiles[2] := permFileNum: {from HPFOPEN} inputfiles[3] := 0; {last is always zero} 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.
Creating Core Routines That Sort and Merge Initializing a Sort or Merge HPSORTINIT or HPMERGEINIT intrinsics. const designator = domain = access = record_size= var outFileNum status outFile new write size 2; {HPFOPEN formaldesignator= option} 3; {HPFOPEN file domain= option} 11; {HPFOPEN access type option #3} 19; {HPFOPEN record length option #3} : : : : : : INTEGER; INTEGER; packed array [1..
Creating Core Routines That Sort and Merge Initializing a Sort or Merge The options are outputoption equals: 0 Output record format is the same as the input record format (default). 1 Each output record contains a 32-bit integer in binary format that indicates the logical record number of the record. The logical record number assigned to each record is the original record order (the first record is logical record zero, the second record is logical record one, and so on).
Creating Core Routines That Sort and Merge Initializing a Sort or Merge This is the output format: Jones, 3 000001 Each output record contains the logical record number (in binary format) followed by the key fields. The output format appears the same as for option 2, but the logical record number is stored in the first two bytes of the record. To view the logical record number, use the FCOPY utility or the ASCII intrinsic, as in outputoption = 1.
Creating Core Routines That Sort and Merge Initializing a Sort or Merge 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: var num_keys : INTEGER; keys : array [1..4] of INTEGER; . . . num_keys := 1; keys [1] := 1 {key begins} keys [2] := 20; {key length} keys [3] := 0; {byte data } keys [4] := 0; {ascending order} The keys parameter is an integer array; each key contains four elements you specify.
Creating Core Routines That Sort and Merge Initializing a Sort or Merge This is a COBOL data type. 7 Display leading sign. This is a COBOL data type. 8 Display trailing sign separate. This is a COBOL data type. 9 Display leading sign separate. This is a COBOL data type. 10 Character. This data type is used in Native Language situations, when you have character data (as in option 0), but will be using a Native Language collating sequence. 11 Reserved. 12 Short floating point decimal.
Creating Core Routines That Sort and Merge Initializing a Sort or Merge Specifying Data and Sequence If your key is a character or byte data type, you may use the altseq parameter to specify two things. • The data type of your input key. • The collating sequence (sort order) you want the sort to follow. The altseq parameter is an array with two parts. The first element of the array is defined by the following table.
Creating Core Routines That Sort and Merge Initializing a Sort or Merge Using HPSORTINIT The following code segment demonstrates the the HPSORTINIT intrinsic. The parameters used are those already discussed. var status inputfiles outputfile outputoption NumKeys keys altseq : : : : : : : INTEGER; array [1..3] array [1..2] INTEGER; INTEGER; array [1..4] array [1..
Creating Core Routines That Sort and Merge Initializing a Sort or Merge Note that the HPMERGEINIT intrinsic call is different from the HPSORTINIT intrinsic call. var status inputfiles outputfile keysonly numKeys keys altseq : : : : : : : INTEGER; array [1..3] array [1..2] INTEGER; INTEGER; array [1..4] array [1..
Creating Core Routines That Sort and Merge Ending Sorting or Merging Ending Sorting or Merging You end the sorting or merging process with HPSORTEND or HPMERGEEND. The syntax for HPSORTEND and HPMERGEEND is: HPSORTEND (status, statistics); HPMERGEEND (status, statistics); The part of the core routine example at the end of the chapter that uses the HPSORTEND intrinsic follows. var status : INTEGER . . .
Creating Core Routines That Sort and Merge Error Checking Error Checking The status parameter of HPSORTINIT and HPMERGEINIT is a 32-bit integer variable that returns the status of each sort or merge intrinsic call. If no errors or warnings are encountered, status returns 32 bits of zero. If errors are encountered, status is interpreted as two 16-bit fields. Bits (0:16), the leftmost halfword, is status.info. A negative value here indicates an error condition. Bits (16:16) are status.subsys.
Creating Core Routines That Sort and Merge Error Checking The following is part of the core sort example, and shows how HPSORTERRORMESS is used. var status : INTEGER; {from a HPSORT intrinsic call} message : array [1..
Creating Core Routines That Sort and Merge Example of Core Sorting Routine Example of Core Sorting Routine The following program sorts the personnel files shown below. They are sorted together by last name. The record size is determined by the input files. The status parameter is checked after the calls to HPSORTINIT and HPSORTEND.
Creating Core Routines That Sort and Merge Example of Core Sorting Routine Example 2-1.
Creating Core Routines That Sort and Merge Example of Core Sorting Routine procedure DO_SORT; var inputfiles outputfile outputOption numKeys keys altseq message length statistics : : : : : : : : : array [1..3] array [1..2] INTEGER; INTEGER; array [1..4] packed array packed array INTEGER; array [1..6] of INTEGER; of INTEGER; of INTEGER; [1..2] of CHAR; [1..
Creating Core Routines That Sort and Merge Example of Core Sorting Routine securityCode : SHORTINT; begin disposition := 0; securityCode := 0; FCLOSE (tempFileNum, disposition, securityCode); FCLOSE (permFileNum, disposition, securityCode); disposition := 1; FCLOSE (outFileNum, disposition, securityCode); end; begin {main} OPEN_FILES; DO_SORT; CLOSE_FILES; end. When this program is executed, the output from the sort is written to ALLEMP.
Creating Core Routines That Sort and Merge Example of Core Merging Routine Example of Core Merging Routine The following program merges the personnel files shown at the beginning of the previous example. The input files are already sorted by employee number. In this example, the files are merged by employee number. The record size is determined by the input files. The status parameter is checked after the calls to HPMERGEINIT and HPMERGEEND. Example 2-2.
Creating Core Routines That Sort and Merge Example of Core Merging Routine size := 80; outFile := '%ALLEMP%'; HPFOPEN (oOutFileNum, status, designator, outFile, domain, new, access, write, record_size, size); end; procedure DO_MERGE; var inputfiles outputfile keysonly numKeys keys altseq message length : : : : : : : : array [1..3] array [1..2] INTEGER; INTEGER; array [1..4] packed array packed array INTEGER; of INTEGER; of INTEGER; of INTEGER; [1..2] of CHAR; [1..
Creating Core Routines That Sort and Merge Example of Core Merging Routine procedure CLOSE_FILES; var disposition : SHORTINT; securityCode : SHORTINT; begin disposition := 0; securityCode := 0; FCLOSE (tempFileNum, disposition, securityCode); FCLOSE (permFileNum, disposition, securityCode); disposition := 1; FCLOSE (outFileNum, disposition, securityCode); end; begin {main} OPEN_FILES; DO_MERGE; CLOSE_FILES; end. When this program is executed, the output is written to ALLEMP.
3 Input and Output by Record Record input and output are optional I/O methods for SORT/XL and MERGE/XL. This chapter presents a general overview of the record options. Next, the intrinsics used for input by record are described, and an example is provided. Last, the intrinsics for output by record are described, and an example provided. (The default I/O methods, input and output by files, are discussed in Chapter 2.) Using Record Input and Output As shown in Figure 3-1.
Input and Output by Record Record Input example, if your program accepts input from a terminal). Record input is only available for SORT/XL. Choose the output by record option when you want to sort or merge information during a program's execution without directly storing the information. For example, use it if you want to display a sorted list to a user's terminal, or if you want a chance to modify the output before storing in a file.
Input and Output by Record Example of Record Input Example of Record Input The following program sorts the personnel files shown below. They are sorted by last name. The program marks the employee numbers of the temporary employees with an asterisk. These two files, TERMEMP and PERMEMP, are used in the following example. (The data descriptions in the top line, and the character positions along the bottom do not appear in the file. They are for your convenience only.
Input and Output by Record Example of Record Input const designator domain access record_size = = = = var tempfile permfile outfile permanent new write size packed array [1..10] of CHAR; packed array [1..10] of CHAR; packed array [1..
Input and Output by Record Example of Record Input recLength,, numKeys, keys, altseq,,,,,); length := 72; {read 72 characters} repeat {read temporary employee file by record} Lngth := FREAD (TempFileNum, Buffer, Length); Buffer[40] := '*'; {Mark the record} if Lngth <> 0 then HPSORTINPUT (Status, Buffer, Length); until Lngth = 0; repeat {read permanent employee file by record} lngth := FREAD (permfilenum, buffer, length); if lngth <> 0 then HPSORTINPUT (status, buffer, length) until lngth = 0; HPSORTEND (
Input and Output by Record Record Output Record Output Record output is useful when you want to create temporary output of a set of sorted or merged data, to create a subset of the sorted or merged information, or to alter the records before outputting them. To output from SORT-MERGE/XL by record, use either the HPSORTOUTPUT or HPMERGEOUTPUTintrinsic. The syntax is: HPSORTOUTPUT (status, buffer, length); HPMERGEOUTPUT (status, buffer, length); The buffer parameter contains the record to be input.
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.
Input and Output by Record Example of Record Output buffer : packed array [1..
Input and Output by Record Example of Record Output Jones, Rields, Smith, Washington, Chapter 3 Eliza Evelyn James Lois Empl. Empl. Empl. Empl.
Input and Output by Record Example of Record Output 50 Chapter 3
4 Altering the Collating Sequence This chapter describes choosing an optional, or alternate, collating sequence. The chapter begins with a discussion of when or why you would want to do this. The middle of the chapter tells you how to specify alternate ASCII sequences, and concludes with a Pascal example. The chapter ends with directions for NL (native language) collating sequences.
Altering the Collating Sequence Sorting and Arranging Sorting and Arranging When you begin a sort, you must specify the keys, the place where records will be compared. Then, the keys of each record are compared and put into a hierarchichal arrangment. The resulting arrangement depends two things: the sequence and the order. You must specify both. The sequence determines what follows what: for example, 0,1,2,...,9 in digits.
Altering the Collating Sequence Altering the Sequence Altering the Sequence You can specify an alternate sequence in the altseq parameter of the HPSORTINIT or HPMERGEINIT intrinsic. (The default sequence is ASCII.) Only ASCII type is allowed to request alternate sequences; when you specify an alternate collating sequence, you must set the keys parameter data type to zero (byte data). The altseq parameter accepts a array. The first element of the array is set by the following table.
Altering the Collating Sequence Example of Using an Altered Sequence Example of Using an Altered Sequence The following example sorts the data file DATA. The entries in DATA are sorted using an altered collating sequence that is explicitly specified in the program. The sequence contains all displayable ASCII characters and alters the order of the alphabetic characters to AaBbCc ....The output file is called FRUIT. DATA - a file of fruit names banana Apple Grapes grapes Pear peach orange Example 4-1.
Altering the Collating Sequence Example of Using an Altered Sequence begin datafile := '%DATA%'; permanent := 1; HPFOPEN (dataFileNum, status, designator, datafile, domain, permanent) ; new := 4; write := 1; size := 80; fruitfile := '%FRUIT%'; HPFOPEN (fruitFileNum, status, designator, fruitfile, domain, new, access, write, record_size, size); end; Procedure DO_SORT; var inputfiles outputfile outputOption numKeys keys altseq : : : : : : array [1..2] array [1..2] INTEGER; INTEGER; array [1..
Altering the Collating Sequence Example of Using an Altered Sequence HPSORTINIT (status, inputfiles, outputfile, outputOption,,, numKeys, keys, altseq,,,statistics,,); {Check for errors in HPSORTINIT} HPSORTEND (Status, ); end; {Check for errors in HPSORTINIT} Procedure CLOSE_FILES; var disposition : SHORTINT; securityCode : SHORTINT; Begin disposition := 0; securityCode := 0; FCLOSE (dataFileNum, disposition, securityCode); disposition := 1; FCLOSE (fruitFileNum, disposition, securityCode); end; begin {
Altering the Collating Sequence Using a Native Language Sequence Using a Native Language Sequence When you sort or merge information that has language considerations, you do so by using a collating sequence for Native Language types. These collating sequences include language-specific alphanumeric characters and accent marks. Parameters in the HPSORTINIT or HPMERGEINIT intrinsic are used when specifying an alternate collating sequence.
Altering the Collating Sequence Using a Native Language Sequence Specifying Parameters You then specify the keys and charseq parameters for the HPSORTINIT or HPMERGEINIT intrinsic as follows: var keys : array [1..4] of INTEGER; charseq : array [1..
5 Getting SORT-MERGE/XL Information SORT-MERGE/XL provides statistical information about the sorting or merging operation just completed, and title and version information about SORT-MERGE/XL. The HPSORTSTAT and HPMERGESTAT intrinsics display status information about their processes. The HPSORTTITLE and HPMERGETITLE intrinsics display title and version information for their processes. As shown in Figure 5-1. you may get title and version information at any point in your program.
Getting SORT-MERGE/XL Information Getting Statistical Information :RUN SORTPROG;STDLIST = OUTFILE :END OF PROGRAM You may also redirect $STDLIST to a back-referenced file or to $NULL. Getting Statistical Information For comparison or other purposes, SORT-MERGE/XL allows you to report statistical information.
Getting SORT-MERGE/XL Information Example of Getting Sort/Merge Statistics Example of Getting Sort/Merge Statistics Using the statistics parameter in the HPSORTINIT and HPSORTEND intrinsics, and calling HPSORTSTAT from the core sorting routine example in Figure 2-1.
Getting SORT-MERGE/XL Information Getting Version and Title Information Getting Version and Title Information You can print the version of SORT-MERGE/XL, the title of the HPSORTLIB or HPMERGELIB segment, the date, and the time to $STDLIST. Syntax for HPSORTTITLE and HPMERGETITLE is: HPSORTTITLE (status); HPMERGETITLE (status); The HPSORTTITLE or HPMERGETITLE intrinsic may be called anywhere in your program after you have declared the system intrinsics.
A HPSORT Intrinsic Status Returns The following table lists the error number, message, cause, and user corrective action for status returns from the HPSORT intrinsics. SORT/XL's subsystem ID is 195. -1 -2 -3 -4 MESSAGE If you specified the keycompare parameter, you can not specify the keys and numkeys parameters. CAUSE You specified the keycompare and the keys and numkeys parameters in the HPSORTINIT intrinsic.
HPSORT Intrinsic Status Returns -5 -6 -7 -8 -9 -10 -11 64 MESSAGE FREAD error on the scratch file. CAUSE Internal SORT/XL error. ACTION Contact your Hewlett-Packard representative. MESSAGE Illegal output option. CAUSE You specified the outputoption parameter in HPSORTINIT to be less than zero or greater than three. ACTION Set the outputoption parameter to 0, 1, 2, or 3. MESSAGE The scratch file cannot be opened.
HPSORT Intrinsic Status Returns -12 -13 -14 -15 -16 -17 -18 Appendix A MESSAGE Illegal key code. CAUSE The 3rd element in the keys array parameter in HPSORTINIT is less than 0 or greater than 13. ACTION Set the 3rd element in the keys array parameter to a value that is from 0-13 inclusive. MESSAGE Insufficient stack space. CAUSE Input file was opened with NOBUFF and MULTI options. The stack was used for blocking/deblocking the file and has insufficient space.
HPSORT Intrinsic Status Returns -19 -20 -21 -22 -23 -24 -25 -26 66 MESSAGE FWRITE error on the output file. CAUSE CCL returned from the FWRITE intrinsic called from SORT/XL. ACTION Make sure your output file number has not been corrupted. Also refer to the MPE XL Intrinsics Reference Manual. MESSAGE FCLOSE error on the scratch file. CAUSE SORT/XL internal error. ACTION Contact your Hewlett-Packard representative. MESSAGE $NULL is not a valid input file.
HPSORT Intrinsic Status Returns -27 -28 -29 -30 -31 -32 -33 Appendix A MESSAGE Failure of FFILEINFO (inputfile). CAUSE CCL returned from the FFILEINFO intrinsic called from SORT/XL. ACTION Make sure that the input file number is not corrupted. Also refer to the MPE XL Intrinsics Reference Manual. MESSAGE Failure of FFILEINFO (outputfile). CAUSE CCL returned from the FFILEINFO intrinsic called from SORT/XL. ACTION Make sure that the output file number is not corrupted.
HPSORT Intrinsic Status Returns -34 -35 -36 -37 -38 -39 68 MESSAGE FGETINFO failure on the two-byte collating sequence table. CAUSE CCL returned from the FGETINFO intrinsic called from SORT/XL. ACTION Make sure the file number passed in charseq is not corrupted. Also refer to the MPE XL Intrinsics Reference Manual. MESSAGE FREAD error on the two-byte collating sequence table. CAUSE CCL returned from the FREAD intrinsic called from SORT/XL.
HPSORT Intrinsic Status Returns -40 -41 -190 -191 -193 -199 Appendix A MESSAGE PRINT intrinsic failed in HPSORTTITLE. CAUSE You redirected output from HPSORTTITLE to a file that is too small; HPSORTTITLE requires two records to output information. ACTION Allow room for at least two records when you redirect output from HPSORTTITLE to a file. MESSAGE PRINT intrinsic failed in HPSORTSTAT.
HPSORT Intrinsic Status Returns -200 -201 -202 -203 -204 -250 -251 -252 70 MESSAGE Insufficient memory allocated for the record size. CAUSE You are trying to sort more data than SORT/XL can handle. ACTION If you are sorting one large file, break it into several smaller files. If you are sorting many large files, sort them individually and then merge them with MERGE/XL. MESSAGE Open of storage area failed. CAUSE Internal SORT/XL error. ACTION Contact your Hewlett-Packard representative.
HPSORT Intrinsic Status Returns -253 -254 -255 -256 -257 -258 -259 Appendix A MESSAGE PROBE failure on the keys parameter of the HPSORTINIT intrinsic. CAUSE The address specified in the keys parameter is not within the allowable address range. ACTION Check the value of the keys parameter. MESSAGE PROBE failure on the altseq parameter of the HPSORTINIT intrinsic. CAUSE The address specified in the altseq parameter is not within the allowable address range.
HPSORT Intrinsic Status Returns -260 -261 -262 -263 -264 -265 -266 72 MESSAGE PROBE failure on the status parameter of the HPSORTOUTPUT intrinsic. CAUSE The address specified in the status parameter is not within the allowable address range. ACTION Check the value of the status parameter. MESSAGE PROBE failure on the buffer parameter of the HPSORTOUTPUT intrinsic. CAUSE The address specified in the buffer parameter is not within the allowable address range.
HPSORT Intrinsic Status Returns -267 -268 -269 -270 -990 -992 -993 -994 -995 Appendix A MESSAGE PROBE failure on the length parameter of the HPSORTERRORMESS intrinsic. CAUSE The address specified in the length parameter is not within the allowable address range. ACTION Check the value of the length parameter. MESSAGE PROBE failure on the status parameter of the HPSORTSTAT intrinsic. CAUSE The address specified in the status parameter is not within the allowable address range.
HPSORT Intrinsic Status Returns -996 -997 -998 -999 -1000 74 MESSAGE SWITCH_TO_CM error on the SORTOUTPUT call. CAUSE Internal SORT/XL error. ACTION Contact your Hewlett-Packard representative. MESSAGE SWITCH_TO_CM error on the SORTINPUT call. CAUSE Internal SORT/XL error. ACTION Contact your Hewlett-Packard representative. MESSAGE SWITCH_TO_CM error on the SORTGETHIDP call. CAUSE Internal SORT/XL error. ACTION Contact your Hewlett-Packard representative.
B HPMERGE Intrinsic Status Returns The following table lists the error number, message, cause, and user corrective action for status returns for all HPMERGE intrinsics. MERGE/XL's subsystem ID is 196. -3 -4 -5 -6 -7 MESSAGE No inputfiles parameter was specified. CAUSE You did not specify the inputfiles parameter in the HPMERGEINIT intrinsic. ACTION Specify the inputfiles parameter. MESSAGE Neither an outputfiles nor a postprocessor parameter was specified.
HPMERGE Intrinsic Status Returns -8 -9 -10 -11 -12 -13 76 MESSAGE The key field is not within the record length of each file. CAUSE One or more files have shorter record lengths and at least one key field extends outside of the file's record length. ACTION Make sure your files are of the correct length and that your key field in within range of the records. MESSAGE Illegal ascending/descending code. CAUSE The fourth element of the keys array parameter is not 1 or 0.
HPMERGE Intrinsic Status Returns -14 -15 -16 -17 -18 -19 Appendix B MESSAGE The input record does not include all key fields. CAUSE You are using variable length records that contain records that not long enough to contain the key fields. ACTION Set the key field in the keys parameter to be contained in the shortest record length or make sure that your shortest record is long enough to contain all your keys.
HPMERGE Intrinsic Status Returns -21 -22 -23 -24 -25 -26 -27 78 MESSAGE Sort language is not supported. CAUSE The language specified in the second element of the charseq parameter array in HPMERGEINIT is not supported on your system. ACTION Check valid language IDs by running NLUTIL. Set the second element of the charseq parameter array to a valid language ID. MESSAGE NLINFO error obtaining the length of the collating sequence table.
HPMERGE Intrinsic Status Returns -28 -29 -30 -31 -40 -41 Appendix B MESSAGE The file is not a valid two-byte collating sequence table. CAUSE Error returned from NLINFO intrinsic called from MERGE/XL. ACTION Check the file type. Also refer to the MPE XL Intrinsics Reference Manual. MESSAGE Two-byte xxxx undefined in the collating sequence table; the largest number is assigned. CAUSE The two-byte value, xxxx, is undefined. ACTION Change xxxx to the correct value.
HPMERGE Intrinsic Status Returns -109 -250 -251 -252 -253 -254 -255 80 MESSAGE Illegal numkeys parameter. CAUSE You specified the numkeys parameter in HPMERGEINIT to not correlate to the number of keys in the keys parameter. ACTION Set the numkeys parameter to correspond to the number of keys that you specified in the keys parameter. MESSAGE PROBE failure on the status parameter of the HPMERGEINIT intrinsic.
HPMERGE Intrinsic Status Returns -256 -260 -261 -262 -263 -264 -265 Appendix B MESSAGE PROBE failure on the charseq parameter of the HPMERGEINIT intrinsic. CAUSE The address specified in the charseq parameter is not within the allowable address range. ACTION Check the value of the charseq parameter. MESSAGE PROBE failure on the status parameter of the HPMERGEOUTPUT intrinsic. CAUSE The address specified in the status parameter is not within the allowable address range.
HPMERGE Intrinsic Status Returns -266 -267 -268 -269 -270 -993 -994 -995 82 MESSAGE PROBE failure on the message parameter of the HPMERGEERRORMESS intrinsic. CAUSE The address specified in the message parameter is not within the allowable address range. ACTION Check the value of the message parameter. MESSAGE PROBE failure on the length parameter of the HPMERGEERRORMESS intrinsic. CAUSE The address specified in the length parameter is not within the allowable address range.
HPMERGE Intrinsic Status Returns -996 -997 -998 -999 -1000 Appendix B MESSAGE SWITCH_TO_CM failed on the MERGEEND1 call. CAUSE Internal MERGE/XL error. ACTION Contact your Hewlett-Packard representative. MESSAGE SWITCH_TO_CM failed on the MERGEOUTPUT call. CAUSE Internal MERGE/XL error. ACTION Contact your Hewlett-Packard representative. MESSAGE SWITCH_TO_CM failed on the MERGEGETHIDP call. CAUSE Internal MERGE/XL error. ACTION Contact your Hewlett-Packard representative.
HPMERGE Intrinsic Status Returns 84 Appendix B
C ASCII/EBCDIC Table The following table shows ASCII and EBCDIC character code values along with their decimal, octal, and hexadecimal equivalents. Abreviations, such as NUL and SOH are spelled out at the end of the table, in order of appearance. Table C-1.
ASCII/EBCDIC Table Table C-1.
ASCII/EBCDIC Table Table C-1.
ASCII/EBCDIC Table Table C-1.
ASCII/EBCDIC Table Table C-1.
ASCII/EBCDIC Table Table C-1.
ASCII/EBCDIC Table Table C-1.
ASCII/EBCDIC Table Table C-1.
ASCII/EBCDIC Table Table C-1.
ASCII/EBCDIC Table Table C-1.
ASCII/EBCDIC Table NUL SOH Null Start of Heading STX Start of Text ETX End of Text EOT End of Transmission ENQ Enquiry ACK acknowledge BEL Bell BS Backspace HT Horizontal Tabulation LF Line Feed VT Vertical Tabulation FF Form Feed CR Carriage Return SO Shift Out SI Shift In DLE Data Link Escape DC1 Device Control 1 (X-ON) DC2 Device Control 2 DC3 Device Control 3 (X-OFF) DC4 Device Control 4 NAK Negative Acknowledge SYN Synchronous Idle ETB End of Transmission B
ASCII/EBCDIC Table 96 Appendix C
D FORTRAN Program Examples The following examples are included in this appendix (the location of the topic discussion is indicated in parentheses): • Example of Core Sorting Routine (Chapter 2) - SORTFILE • Example of Core Merging Routine (Chapter 2) - MERGEFILE • Example of Record Input (Chapter 3) - SORTREC_INPUT • Example of Record Output (Chapter 3) - SORTREC_OUTPUT • Example of Using an Altered Sequence (Chapter 4) - SORTALT 97
FORTRAN Program Examples Example of Core Sorting Routine Example of Core Sorting Routine The following program sorts the personnel files shown below. They are sorted together by last name. The record size is determined by the input files. The status parameter is checked after the calls to HPSORTINIT and HPSORTEND.
FORTRAN Program Examples Example of Core Sorting Routine Example D-1. SORTFILE Program $standard_level system program SORTFILE C C This program reads the files TEMPEMP and PERMEMP, sorts by last name, C and outputs to the file ALLEMP. The compiler directive '$standard_level C system' is used to supress FORTRAN 77 warnings for non-standard features, C which include intrinsics calls.
FORTRAN Program Examples Example of Core Sorting Routine call HPFOPEN (TEMPFILENUM, STATUS, DESIGNATOR, 2 ,TEMPFILE, DOMAIN, PERMANENT) if (STATUS .ne. 0) then PRINT *,STATUS print *,'HPFOPEN error on TEMPEMP. Terminating.' call QUIT (1) endif C PERMFILE = '%PERMEMP%' call HPFOPEN (PERMFILENUM, STATUS, DESIGNATOR, 2 ,PERMFILE, DOMAIN, PERMANENT) if (STATUS .ne. 0) then print *,'HPFOPEN error on PERMEMP. Terminating.
FORTRAN Program Examples Example of Core Sorting Routine OUTPUTFILE(1) = OUTFILENUM OUTPUTFILE(2) = 0 OUTPUT_OPTION NUMKEYS KEYS(1) KEYS(2) KEYS(3) KEYS(4) = = = = = = 0 1 1 20 0 0 ALTSEQ(1:1) ALTSEQ(1:2) = CHAR(255) = CHAR(255) call HPSORTINIT (STATUS, INPUTFILES, OUTPUTFILE, 2 OUTPUT_OPTION,,, NUMKEYS, KEYS, ALTSEQ) if (STATUS .ne. 0) then MESSAGE = ' ' call HPSORTERRORMESS (STATUS, MESSAGE, LENGTH) print *,MESSAGE endif call HPSORTEND (STATUS,STATISTICS) if (STATUS .ne.
FORTRAN Program Examples Example of Core Sorting Routine output: :print allemp Everett, Gangley, Jackson, Jackson, Jones, Rields, Smith, Washington, 102 Joyce Tomas Jonathan Rosa Eliza Evelyn James Lois 000029 000003 000006 000022 000001 000007 000005 000014 10/19/87 06/06/87 06/06/87 08/15/87 06/06/87 07/12/87 06/06/87 07/23/87 Appendix D
FORTRAN Program Examples Example of Core Merging Routine Example of Core Merging Routine The following program merges the personnel files shown at the beginning of the previous example. They are merged by employee number. The record size is determined by the input files. The status parameter is checked after the calls to HPMERGEINIT and HPMERGEEND. Example D-2.
FORTRAN Program Examples Example of Core Merging Routine C DESIGNATOR DOMAIN ACCESS RECORD_SIZE = = = = 2 3 11 19 C TEMPFILE = '%TEMPEMP%' PERMANENT = 1 call HPFOPEN (TEMPFILENUM, STATUS, DESIGNATOR, 2 ,TEMPFILE, DOMAIN, PERMANENT) if (STATUS .ne. 0) then print *,'HPFOPEN error on TEMPEMP. Terminating.' call QUIT (1) endif C PERMFILE = '%PERMEMP%' call HPFOPEN (PERMFILENUM, STATUS, DESIGNATOR, 2 ,PERMFILE, DOMAIN, PERMANENT) if (STATUS .ne. 0) then print *,'HPFOPEN error on PERMEMP. Terminating.
FORTRAN Program Examples Example of Core Merging Routine 2 ,OUTFILENUM, STATUS C INPUTFILES(1) = TEMPFILENUM INPUTFILES(2) = PERMFILENUM INPUTFILES(3) = 0 OUTPUTFILE(1) = OUTFILENUM OUTPUTFILE(2) = 0 KEYS_ONLY NUMKEYS KEYS(1) KEYS(2) KEYS(3) KEYS(4) = = = = = = 0 1 41 20 0 0 ALTSEQ(1:1) ALTSEQ(1:2) = CHAR(255) = CHAR(255) call HPMERGEINIT (STATUS, INPUTFILES,, OUTPUTFILE,, 2 KEYS_ONLY, NUMKEYS, KEYS, ALTSEQ) if (STATUS .ne.
FORTRAN Program Examples Example of Core Merging Routine return end When this program is executed, the output is written to ALLEMP.
FORTRAN Program Examples Example of Record Input Example of Record Input The following program sorts the personnel files shown below. They are sorted by last name. The program marks the employee numbers for the temporary employees with an asterisk.
FORTRAN Program Examples Example of Record Input Example D-3. SORTREC_INPUT Program $standard_level system program SORTREC_INPUT C C This program reads the files TEMPEMP and PERMEMP, alters the TEMPEMP C records, passes all records to SORT/XL, and outputs to the file ALLEMP.
FORTRAN Program Examples Example of Record Input print *, 'HPFOPEN error on TEMPFILE. endif Terminating.' C PERMFILE = '%PERMEMP%' call HPFOPEN (PERMFILENUM, STATUS, DESIGNATOR, 2 ,PERMFILE, DOMAIN, PERMANENT) if (STATUS .ne. 0) then print *, 'HPFOPEN error on PERMEMP. Terminating.' call QUIT (2) endif C NEW = 4 WRITE = 1 SIZE = 80 OUTFILE = '%ALLEMP%' call HPFOPEN (OUTFILENUM, STATUS, DESIGNATOR, 2 ,OUTFILE, DOMAIN, NEW, ACCESS, WRITE, 3 ,RECORD_SIZE, SIZE) if (STATUS .ne.
FORTRAN Program Examples Example of Record Input OUTPUTFILE(1) = OUTFILENUM OUTPUTFILE(2) = 0 OUTPUT_OPTION = 0 RECLENGTH = 80 NUMKEYS KEYS(1) KEYS(2) KEYS(3) KEYS(4) = = = = = 1 1 20 0 0 ALTSEQ(1:1) ALTSEQ(2:2) = CHAR(255) = CHAR(255) call HPSORTINIT (STATUS,, OUTPUTFILE, OUTPUT_OPTION 2 ,RECLENGTH,, NUMKEYS, KEYS, ALTSEQ) if (STATUS .ne. 0) then MESSAGE = ' ' call HPSORTERRORMESS (STATUS, MESSAGE, LENGTH) print *,MESSAGE endif LENGTH = 72 EOF = .false. C C C Read TEMPEMP file.
FORTRAN Program Examples Example of Record Input 60 C continue end do Now read PERMEMP, as explained above. EOF = .false. LNGTH = FREAD (PERMFILENUM, BUFFER, LENGTH) if (ccode()) 70,90,80 70 print *, 'FREAD error on PERMEMP.' call QUIT (70) 80 EOF = .true. 90 continue do while (.not. EOF) call HPSORTINPUT (STATUS, BUFFER, LENGTH) if (STATUS .ne.
FORTRAN Program Examples Example of Record Input C DISPOSITION = 0 SECURITYCODE = 0 C call FCLOSE call FCLOSE DISPOSITION call FCLOSE return end (TEMPFILENUM, DISPOSITION, SECURITYCODE) (PERMFILENUM, DISPOSITION, SECURITYCODE) = 1 (OUTFILENUM, DISPOSITION, SECURITYCODE) When this program is executed, the output is written to ALLEMP.
FORTRAN Program Examples Example of Record Output Example of Record Output The following program sorts the personnel files shown for the last example. They are sorted by last name. The output records are altered before they are output. Example D-4. SORTREC_OUTPUT Program $standard_level system program SORTREC_OUTPUT C C This program reads the files TEMPEMP and PERMEMP, sorts them by last C name, outputs them by record, alters the output recors, and prints the C record to $STDLIST.
FORTRAN Program Examples Example of Record Output endif C PERMFILE = '%PERMEMP%' call HPFOPEN (PERMFILENUM, STATUS, DESIGNATOR, 2 ,PERMFILE, DOMAIN, PERMANENT) if (STATUS .ne. 0) then print *, 'HPFOPEN error on PERMEMP. Terminating.
FORTRAN Program Examples Example of Record Output print *,MESSAGE endif C do while (LENGTH .gt. 0) call HPSORTOUTPUT (STATUS, BUFFER, LENGTH) BUFFER(33:39) = 'Empl. #' BUFFER(50:59) = 'Hire Date:' print *,BUFFER if (STATUS .ne. 0) then call HPSORTERRORMESS (STATUS, MESSAGE, LENGTH) print *,MESSAGE endif end do C call HPSORTEND (STATUS) if (STATUS .ne.
FORTRAN Program Examples Example of Using an Altered Sequence Example of Using an Altered Sequence The following example sorts the data file below, DATA. The entries in DATA are sorted using an altered collating sequence that is explicitly specified in the program. The sequence contains all displayable ASCII characters and alters the order of the alphabetic characters to AaBbCc ....
FORTRAN Program Examples Example of Using an Altered Sequence Example D-5. SORTALT Program $standard_level system program SORTALT C C This program reads the files TEMPEMP and PERMEMP, sorts them by last C name, outputs them by record, alters the output recors, and prints the C record to $STDLIST.
FORTRAN Program Examples Example of Using an Altered Sequence NEW = 4 WRITE = 1 SIZE = 80 FRUITFILE = '%FRUIT%' call HPFOPEN (FRUITFILENUM, STATUS, DESIGNATOR, 2 ,FRUITFILE, DOMAIN, NEW, ACCESS, WRITE 3 ,RECORD_SIZE, SIZE) if (STATUS .ne. 0) then print *, 'HPFOPEN error on FRUITFILE. Terminating.
FORTRAN Program Examples Example of Using an Altered Sequence ALTSEQ(34:49) ALTSEQ(50:65) ALTSEQ(66:80) ALTSEQ(81:95) = = = = '@AaBbCcDdEeFfGgH' 'hIiJjKkLlMmNnOoP' 'pQqRrSsTtUuVvWwX' 'xYyZz[\]^^_{|}~' C call HPSORTINIT (STATUS, INPUTFILES, OUTPUTFILE 2 ,OUTPUT_OPTION, ,,, NUMKEYS, KEYS 3 ,ALTSEQ,,,STATISTICS) if (STATUS .ne. 0) then MESSAGE = ' ' call HPSORTERRORMESS (STATUS, MESSAGE, LENGTH) print *,MESSAGE endif C call HPSORTEND (STATUS) if (STATUS .ne.
FORTRAN Program Examples Example of Using an Altered Sequence 120 Appendix D
E Data Types When you sort or merge data with SORT-MERGE/XL, your sorting key is one of many data types. This appendix explained the format of SORT-MERGE/XL's generic data types and gives language equivalents of them. For more information about data types, refer to Data Types Conversion Programmer's Guide. In HPSORTINIT or HPMERGEINIT you specify the type of data that is sorted by your keys. The data type is given in the third element of the keys parameter array.
Data Types HP Business BASIC HP Business BASIC Table E-1.
Data Types HP C/XL HP C/XL Table E-2.
Data Types HP COBOL II/XL HP COBOL II/XL Table E-3.
Data Types HP FORTRAN 77/XL HP FORTRAN 77/XL Table E-4.
Data Types HP Pascal HP Pascal Table E-5.
Index Symbols $NULL, 19 $STDLIST, 59, 60 A accessing input files, 21 accessing HPSORT-MERGE/XL through COBOL, 20 accessing HPSORT-MERGE/XL through FORTRAN, 21 ALLEMP, example file, 37, 40, 45, 102, 106, 112 altering the collating sequence, 53 introduction to, 51 ALTSEQ, example file, 53 altseq, intrinsic parameter, 53, 57 ascending, 27 ASCII table, 85 ASCII, intrinsic, 24, 25 B BASIC data types, 122 buffer, intrinsic parameter, 42, 46 building a file, 59 Business BASIC data type, 27 Business BASIC data typ
Index TEMPEMP, 43, 98, 107 example of core merging routine - FORTRAN, 103 core merging routine - Pascal, 38 core sorting routine - FORTRAN, 98 core sorting routine - Pascal, 34 record input - FORTRAN, 107 record input - Pascal, 43 record output - FORTRAN, 113 record output - Pascal, 47 statistical output from MERGE/XL, 61 statistical output from SORT/XL, 61 using a Native Language collating sequence, 57 using an altered collating sequence FORTRAN, 116 using an altered collating sequence - Pascal, 54 using
Index syntax, 31 HPSORTERRORMESS, intrinsic, 13, 16, 29 syntax, 32 HPSORTINIT, intrinsic, 13, 18, 21, 29 syntax, 19 HPSORTINPUT, intrinsic, 13, 42 syntax, 42 HPSORTOUTPUT, Intrinsic, 46 HPSORTOUTPUT, intrinsic, 13 syntax, 46 HPSORTSTAT, intrinsic, 13, 60 syntax, 60 HPSORTTITLE, intrinsic, 13, 62 syntax, 62 I identification number for subsystems, 16 IEEE Standard floating point, 123 IEEE standard floating point, 125, 126 IEEE standard floating-point data type, 26 Initializing MERGE/XL, 21 initializing MERGE
Index specifying, 26 specifying data type of, 26 specifying length of, 26 keys, intrinsic parameter, 26, 53, 57 keysonly, intrinsic parameter, 25 L language equivalents of data types, 121 Large File Support, 16 length, intrinsic parameter, 32, 42, 46 logical record number, 24, 25 M magnetic tape input, 22 maximum record length, 16 MERGE/XL ending, 18, 31 error checking, 29 getting statistical information, 60 getting title and version information, 62 initialization, 18, 19, 21, 29 outputting individual reco
Index FORTRAN example of, 107 introduction to, 41 Pascal example of, 43 record input From SORT/XL, 42 record number, logical, 24, 25 record output FORTRAN example of, 113 introduction to, 41 Pascal example of, 47 record output from MERGE/XL, 46 record output from SORT/XL, 46 redirecting output, 59 S secondary key, 15 sequence, collating - refer to collating sequence, 15 sequence, ordering, 27 short floating point decimal data type, 122 short floating-point decimal data type, 27 SORT/XL ending, 18, 31 erro
Index HPMERGEINIT, example of, 29 HPSORTEND, example of, 31 HPSORTERRORMESS, example of, 32 HPSORTINIT, example of, 29 HPSORTINPUT, example of, 42 HPSORTOUTPUT, example of, 46 HPSORTSTAT, example of, 60 HPSORTTITLE, example of, 62 NLUTIL, example of, 57 utility FCOPY, 24 MERGE/XL, 53 NLUTIL, 57 SORT/XL, 53 SORT-MERGE/XL, 11 V version and title information example of output from MERGE/XL, 62 example of output from SORT/XL, 62 getting from MERGE/XL, 62 getting from SORT/XL, 62 132 Index