Table of Contents

DMSSRT Abstract

Statistics

Type ASSEMBLE
Source Lines : 745
Fixes Applied : 3
Most Recent Version : Tuesday, December 12, 1978
Last Fix ID : [HRC323DS]

Synopsis

Module

     DMSSRT    (SORT)

Function

       TO  ARRANGE RECORDS  WITHIN A  FILE  IN A  DESCENDING
       SEQUENTIAL ORDER.

Attributes

     DISK RESIDENT

Operation

       FROM THE REQUESTED FIELD DEFINITIONS, SORT SETS UP AN
       ORDERED SERIES OF MVC'S AT  THE BEGINNING OF THE FREE
       AREA, IN WHICH THE 'FROM' FIELD IS INPUT RECORD FIELD
       LOCATION, THE LENGTH IS THE  LENGTH OF THE FIELD, AND
       THE 'TO'  LOCATION IS THE  START OF  THE DISTRIBUTION
       BUFFER PLUS THE LENGTH OF  ANY FIELDS WHICH HAVE COME
       BEFORE.  THUS, A  PRIMARY FIELD OF LENGTH  5 WOULD BE
       MOVED INTO DISTRIBUTION BUFFER  LOCATION 0, WHILE THE
       SECONDARY  FIELD,   IF  ANY   WOULD  BE   MOVED  INTO
       DISTRIBUTION BUFFER LOCATION 0 PLUS 5.  THUS A SINGLE
       CONTIGUOUS SORT  ELEMENT IS  CREATED WHOSE  LENGTH IS
       THE TOTAL LENGTH OF ALL THE FIELDS.

       RECORDS ARE  READ IN ONE  AT A TIME   INTO CONTIGUOUS
       AREAS OF STORAGE. A SORT  ELEMENT IS CREATED WHICH IS
       THEN PLACED IN ASCENDING ORDER  IN A SORT TREE, WHERE
       EACH ENTRY HAS THE FOLLOWING FORMAT:

            DC   AL3(LOW)
            DC   AL3(HIGH)
            DC   AL3(BACK)
            DC   XL1(FLAG)
            DC   AL2(CNT)
            DC   AL ELEMENT LENGTH PLUS 2 BYTES FOR ITEM NO.

            LOW  IS ADDRESS OF NEXT LOWER ENTRY
            HIGH IS ADDRESS OF NEXT HIGHER ENTRY
            BACK IS BACK POINTER TO PREVIOUS ENTRY
            FLAG IS USED IN UNWINDING THE TREE TO MARK A DELETED ELEM
            CNT  INDICATES NUMBER OF DUPLICATES

       WHEN  THE  TREE  HAS BEEN  COMPLETED,  THE  CHAIN  IS
       SEARCHED FOR  THE LOWEST ELEMENT, WHICH  IS SIGNIFIED
       BY A  LOW FIELD  OF ALL  ZEROS.  THE  FLAG IS  SET TO
       'USED'.  RDBUF  IS CALLED WITH  THE ITEMNO  WHICH WAS
       SAVED IN  THE MODE.  WRBUF WRITES  THE RECORD  OUT ON
       DISK. THE  CHAIN IS THEN  UNWOUND UPWARDS,  WITH EACH
       DELETED  ENTRY BEING  FLAGGED  AND THE  CORRESPONDING
       RECORD  WRITTEN   OUT,  UNTIL  THE  ENTIRE   TREE  IS
       EXHAUSTED AND THE SORTED FILE  IS WRITTEN.  THE INPUT
       AND OUTPUT FILES ARE CLOSED, STORAGE IS RELEASED, THE
       PAGES RELEASED,  AND CONTROL  IS PASSED  BACK TO  THE
       CALLER.