FastSort Manual

Sorting Programmatically
FastSort Manual429834-003
4-16
Sorting From TAL Programs
Example 4-3. TAL Example of a Serial Sort Run (page 1 of 3)
?SYMBOLS, NOCODE, INSPECT, MAP, LMAP
!-----------------------------------------------------------!
! FastSort Serial Sort Run !
!-----------------------------------------------------------!
! This program sends input records to a SORTPROG process !
! using SORTMERGESEND and then receives the sorted output !
! records using SORTMERGERECEIVE. To reduce interprocess !
! messages, this program uses a blocked interface and de- !
! clares two buffers for nowait I/O for writes to SORTPROG. !
! !
! (Note: This program shows only FastSort procedure calls !
! and does not contain error recovery routines or other !
! features that might be implemented in an actual program.) !
!-----------------------------------------------------------!
! Global declarations. !
!-----------------------------------------------------------!
INT .home^term^name[0:11] := 12*[" "]; ! Terminal name
INT home^term^filenum; ! File number
!-----------------------------------------------------------!
! FastSort control and flags information. !
!-----------------------------------------------------------!
INT .ctlblk[0:199]; ! Control block for sort interface
INT flags := 0; ! SORTMERGESTART flags
INT flags2 := 1; ! SORTMERGESTART flags2 for nowait I/O
INT .key^array[0:3]; ! SORTMERGESTART key field definitions
!-----------------------------------------------------------!
! FastSort block buffers. !
!-----------------------------------------------------------!
LITERAL block^length = 4096;
STRING .block^buffer [0:block^length - 1];
STRING .block^buffer2[0:block^length - 1];
!-----------------------------------------------------------!
! FastSort record information and buffer. !
!-----------------------------------------------------------!
LITERAL max^count = 300; ! Maximum count
INT(32) dcount := 300D; ! Record count
INT .inbuf[0:35]; ! Record buffer
!-----------------------------------------------------------!
! FastSort error and statistics variables. !
!-----------------------------------------------------------!
INT .error^buf[0:31], ! Error message
error^source, ! Error related info
error; ! Error return parameter
INT(32) error^code; ! FastSort and system error codes
INT .statistics[0:20]; ! Statistics buffer
-----------------------------------------------------------!
?PAGE "External Declarations From EXTDECS0"
!-----------------------------------------------------------!
?NOLIST
?SOURCE $SYSTEM.SYSTEM.EXTDECS0 (DEBUG,
? INITIALIZER,
? MYTERM,
? OPEN,
? SORTMERGESTART,
? SORTERRORSUM,
? SORTMERGESTATISTICS,
? SORTBUILDPARM,
? SORTMERGESEND,
? SORTMERGERECEIVE)
?LIST