FastSort Manual

Sorting Programmatically
FastSort Manual429834-003
4-18
Sorting From TAL Programs
length := 70; ! Set length of buffer.
FOR index := 1 TO max^count DO
BEGIN
inbuf := - index; ! Set value to send to SORTPROG.
error := SORTMERGESEND (ctlblk,,
length,,,,
rec^addr);
IF error THEN ! Check for SORTMERGESEND error.
BEGIN
length := SORTERRORSUM (ctlblk,
error^buf,
error^code,
error^source);
! Process the SORTMERGESEND error.
END;
END;
length := -1; ! Indicate all records have been sent.
error := SORTMERGESEND (ctlblk,,
length,,,,
rec^addr);
IF error THEN ! Check for SORTMERGESEND error.
BEGIN
length := SORTERRORSUM (ctlblk,
error^buf,
error^code,
error^source);
! Process the SORTMERGESEND error.
END;
!-----------------------------------------------------------!
! Call SORTMERGERECEIVE to receive records from SORTPROG. !
!-----------------------------------------------------------!
DO
BEGIN
error := SORTMERGERECEIVE (ctlblk,inbuf,length);
IF error THEN ! Check for SORTMERGERECEIVE error.
BEGIN
length := SORTERRORSUM (ctlblk,
error^buf, error^code,
error^source);
! Process the SORTMERGERECEIVE error.
END;
END
!-----------------------------------------------------------!
! Note: At this point, an actual program would process the !
! sorted output records returned from SORTPROG. !
!-----------------------------------------------------------!
UNTIL length = -1 ;
!-----------------------------------------------------------!
! Return SORTPROG completion status and statistics. Set !
! length to return all 21 words of statistics information. !
!-----------------------------------------------------------!
length := 21;
error := SORTMERGESTATISTICS (ctlblk, length, statistics);
IF error THEN ! Check for SORTMERGESTATISTICS error.
BEGIN
length := SORTERRORSUM (ctlblk,
error^buf,
error^code,
error^source);
! Process the SORTMERGESTATISTICS error.
END;
END; ! End of MAIN Procedure !
!-----------------------------------------------------------!
Example 4-3. TAL Example of a Serial Sort Run (page 3 of 3)