FastSort Manual

Sorting Programmatically
FastSort Manual429834-003
4-15
Sorting From TAL Programs
Sorting From TAL Programs
You can call a FastSort procedure directly from a TAL program. The program must
include a declaration for the sort control block and for any variables, constants, and
text identifiers you use in the procedure calls. For information about TAL declarations
and the structure of TAL programs, see TAL Reference Manual.
Example 4-3 on page 4-16 shows a TAL program that calls FastSort procedures to
perform a serial sort run.
*---------------------------------------------------------
* Input: Read input records and release to SORTPROG.
*---------------------------------------------------------
SORTIN-PROCEDURE SECTION.
DISPLAY "Reading input records...".
READ-INPUT.
READ INPUT-FILE NEXT RECORD
AT END GO TO SORTIN-EXIT.
RELEASE SORT-RECORD FROM IN-RECORD.
GO TO READ-INPUT.
SORTIN-EXIT.
EXIT.
*---------------------------------------------------------
* Output: Return sorted records and write to output file.
*---------------------------------------------------------
SORTOUT-PROCEDURE SECTION.
DISPLAY "Writing sorted records...".
RETURN-OUTPUT.
RETURN SCRATCH-FILE
AT END GO TO SORTOUT-EXIT.
MOVE CORRESPONDING SORT-RECORD TO OUT-RECORD.
WRITE OUT-RECORD.
GO TO RETURN-OUTPUT.
SORTOUT-EXIT.
EXIT.
Example 4-2. COBOL85 Example of a Serial Sort Run (page2of2)