LSORT is controlled by a command file (or script) which contains the following keyword statements. Note that LSORT control statement keywords are case-insensitive, but must be specified in the following order to permit proper parsing:
Infile input-filename
Outfile output-filename
Misc Output-Type,Character-Set,Messages,Output-Conversion,Key-To-Use
Record Record-Type,Position,Length,Conversion-Type,Lower-Limit,Upper-Limit
Append-Records
Discard-Duplicate-Records
Fields Field-List
Preserve-Record-Numbers
Mask Mask-List
Infile input-filename
Specify the name of the source file from which all data is to be taken. The filename is specified in DOS format.
Outfile output-filename
Specify the name of the output file to be used to receive the sorted output. The filename is specified in DOS format.
Misc Output-Type,Character-Set,Messages,Output-Conversion,Key-To-Use
Record Record-Type,Position,Length,Conversion-Type,Lower-Limit,Upper-Limit
Append-Records
Adds sort output records to an existing file instead of overwriting the specified output file.
No parameters.
Notes:
The sort output records generated must be of the same record length as the existing output file records. Different record lengths will result in an error report.
This option is inconsistent with the "Preserve-Record-Numbers" option and the specification of both will result in an error report.
Discard-Duplicate-Records
Throw away any records that exactly duplicate each other.
No parameters.
Notes:
This option is inconsistent with the "Preserve-Record-Numbers" option and the specification of both will result in an error report.
Fields Field-List
Specify alternate data output by providing a list of field extraction definitions.
Parameters:
The parameter list consists of an ordered list of single field extraction definitions. A field extraction definition describes either 1) a contiguous field extraction by specifying the record position and length of the field, or 2) a constant string by specifying text in quotes.
All extractions definitions are processed in their specified order to build a new data record by concatenating the extracted data.
A special case exists to provide the current record number of the source data record by specifying a record position of negative 3 and a length of 4 (see the examples below). This results in the inclusion of a 4 bytes record number into the output record in "B 4" format.
Notes:
Multiple FIELDS statements may be specified and the output data generated by each is concatenated as if there were one (very large) FIELDS statement.
Examples:
FIELDS 1,128,"Add this to the end of the record"Copies a 128 byte record and adds text to the end.
FIELDS 1,10,-3,4,11,118Copies the first 10 bytes of a record, followed by the record number in B 4 format, and the next 118 bytes of the record.
FIELDS 1,10," -- spaces -- ",11,118Copies the first 10 bytes of a record, followed by constant text, and the next 118 bytes of the record.
Preserve-Record-Numbers
Copy the source data records to the output file retaining a one-to-one correspondence between the data records and the record numbers. This means that no actual sort is performed and holes in the file caused by deleted records are faithfully reproduced.
No parameters.
Notes:
This option is inconsistent with the "Append-Records" and "Discard-Duplicate-Records" options and the specification of "Preserve-Record-Numbers" with either of these options will result in an error report.
Since no sort activity happens when this option is specified, it is unnecessary to provide a MASK specification. In fact, the use of both "Mask" and "Preserve-Record-Numbers" will result in an error report.
Mask Mask-List
Define sort order to be applied to the output data records.
Parameters:
The parameter list consists of an ordered list of sort field definitions. Each sort field definition contains a starting position within the record, the length of the data field to be sorted, the sort data type, and the sort direction.
The position and length are numeric values. The position starts at position 1.
The sort data type is one of the otherwise familiar data conversion types: B, C, L, N, PD, BU, LB, LBU.
The sort direction is either ascending (represented by "A") or descending (represented by "D").
Notes:
Multiple sort specifications may be included on the single allowed MASK statement. The second and subsequent sort orders only have an effect on the output record order when the earlier sorts result in a tie.
If all specified sorts result in a tie, the record number will be used as a tiebreaker in ascending order. In other words, the order of the set of records in each tie sort group will not be changed.
Examples:
MASK 1,5,C,A
This will result in a file sorted in simple ascending order of the first 5 characters of each record.
MASK 1,2,C,D,4,2,C,A,7,2,C,D
If we assume, for example, that the first 8 characters of the data records contains TIME$ values, the output records will be sorted in descending order by hours (23:xx:xx first) with minutes within the hour in ascending (xx:00:xx first) and seconds descending (xx:xx:59 first).
File
Exit
Record
Mask