20001205 - Program originally written by Chad Kulesa
20001205 - Program modified and documented by Larry Boatman
Purpose: Passed up to four parameters, the first two of which (input and output file
names) are required (sort key offset from beginning of record and length of
sort key are optional), this "generic" sort program reads in the input file
(name passed in the first parameter), performs the sort (see further
documentation below) , and writes out the output file (name passed as second
parameter).
Declare an "assignable" array as the "output" array
if less than or more than the number of arguments then
display a "usage" message
exit program
Open the input file or report why not and exit
Read entire file into an "input" array
Close the input file
Sort the "input" array into the "output" array based on the comparison of sort keys
built depending upon the number of arguments passed to the program as follows:
if no sort key offset and no sort key length is passed, then
sort on entire record
else
if a sort key offset is passed but no sort key length, then
sort on entire record beginning from the sort key offset
else
if both a sort key offset and sort key length is passed, then
sort on key beginning at sort key offset for sort key length
end if
end if
end if
Open the output file
Write the sorted "output" array to the output file
Close the output file