Sort control file

From BR Wiki
Jump to: navigation, search

A sort control file is an internal file made of one or more sort groups. BR produces, one after the other, an output file for each sort group. When multiple sort groups exist in the sort control file, all are executed; BR cannot single a particular sort group out and run it alone. The sort control file can also be created as a PROC file in a text editor. See the example near the top of this page.

The location of the MASK specification signals the end of each sort group in the control file. BR automatically clears all controls set by the previous sort group before it begins executing the next one.

When a control file contains more than one sort group and an error occurs during one of the sorts, only the sorts that have already been successfully completed will be processed.

Creating the Sort Control File

The sort control file can be created by a BR program.

Leading blanks in baseyear sensitive fields are replaced with zeroes for sorting purposes, provided the remainder of the field contains only numeric data.

Note- the Y2K sorting and indexing features interpret year zero as zero (instead of 2000) *IF* the month and day are zero.

Creating the Sort File with a Program

The most common reason for using a program to create a sort control file is to allow the user to select the information to be sorted. The following example demonstrates a program that asks for the range of customer numbers that are to be sorted. This information is then used to create the sort control file's RECORD specification.

00080 !
00090 PRINT FIELDS "20,1,c": "Enter beginning and ending customer"
00100 INPUT FIELDS "21,5,c 5,u;21,15,c 5,u": BC$,EC$
00110 OPEN #1:"name=CUST[WSID].SRT,recl=128,replace",INTERNAL,OUTPUT
00120 FORM C 128
00130 WRITE #1,USING 120: "! Sorting Customer File . . ."
00150 WRITE #1,USING 120: "RECORD I,1,5,C,'" & BC$ & "','" &EC$ & "'"
00160 WRITE #1,USING 120: "MASK 1,5,C,A"
00170 CLOSE #1:
00180 !

For further explanation, see the Sort Facility or the Sort Control File Tutorial.