Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Special registers for files: SORT

In the compiler, four special registers are provided for communication between the programmer and the SORT control routine. Each of these registers is a 4-byte binary data item with a fixed name; the description of each register is PICTURE S9(8) USAGE IS COMPUTATIONAL. The data description entries for the registers are generated automatically by the compiler and cannot be declared by the programmer.

SORT-FILE-SIZE register

The programmer may set the contents of the SORT-FILE-SIZE register to the approximate number of records to be processed in the next sort. This must be done before the SORT statement is executed. From this information, the sort routine calculates how much space it will need on internal working files. SORT-FILE-SIZE is initially set to zero by the compiler; and, if the value of the register is still zero at the time a sort begins, the SORT control routine will make a default space allocation. Thus, the programmer does not have to enter any estimate of file size into this special register, although supplying such information aids the efficiency of the sort. The value entered in the special register by the user (e.g. MOVE 25 TO SORT-FILE-SIZE) is released to the control routine.

SORT-CORE-SIZE register

The programmer may set the contents of the SORT-CORE-SIZE register to the number of bytes of memory that are to be available for use by the SORT routine. This must be done before the SORT statement is executed.

SORT-MODE-SIZE register

SORT-MODE-SIZE may be set if variable-length records are to be sorted.

The programmer may set this register to the most commonly used record length in the input file. The value may not be less than the lowest value and not greater than the highest value in the sort-file description. The appropriate value must be moved into SORT-MODE-SIZE before the execution of the SORT statement. The compiler initializes the contents of this register to zero; and, if the programmer has not supplied any other value before the SORT statement is executed, the maximum record length will be assumed to be the most common record length.

SORT-RETURN register

After a SORT statement or RELEASE/RETURN statement has been executed, the special register SORT-RETURN contains a value to indicate whether the sort has been successful. A value of zero indicates that the sort was successful. A non-zero value indicates that the sort terminated abnormally.

Summary

None of the special registers (except SORT-RETURN) has its value reset or set to zero by the execution of the SORT statement. If a program contains several sorts, the programmer must move appropriate values into the SORT-FILE-SIZE, SORT-CORE-SIZE and SORT-MODE-SIZE registers before each sort is executed.

It should be noted that the special registers are binary items and, therefore, cannot be used as immediate operands of ACCEPT statements.

Example 12-8

ACCEPT MODE-SIZE FROM MASTER-FILE.
MOVE MODE-SIZE TO SORT-MODE-SIZE.

Since the ACCEPT statement transfers input data from the terminal without conversion, the MOVE statement is used to achieve conversion to COMPUTATIONAL.