Information Technology Reference
In-Depth Information
if c-element ( i-sub )(86:5) > c-element ( t-sub )(86:5)
hold-line = c-element ( i-sub )
c-element ( i-sub ) = c-element ( t-sub )
c-element ( t-sub ) = hold-line
end-if
compare the zip codes since they are in position 86 of the each record for a length of 5
and do a swap, if necessary. You can see that
hold-line
is the variable used to accomplish the swap. As a refresher remember that
c-element ( i-s ub)(10:18)
represents the part of one element of the table starting in position 10 for a length of 18,
depending on the variable
i-sub .
That isn't the zip code here, but the last name. When
t-sub = record-count,
this means we just compared the first zip code in the table to the last one and thus we're
done with that group of compares. We next set
process-sw
to 0 again and proceed as we outlined until our sort is complete.
Naturally you won't need to write a sort like this since you should have easier
ways of doing this process. But if you have to, you could write your own sort. This is the
way it was done in the pioneer days of computing. Actually there were a great many more
things you had to do that we take for granted today.
And now for that question in chapter 9: Could a file be read sequentially if we
began at the last record and read the entire file backwards with the first record on the file
being the last record read. In that case, would you get a begin of file rather than an end of
file ? Seriously, if the file we're talking about is the account number file, just sort it by the
account number in descending order. Take the result and read it sequentially and you'll
have the account number file read backwards. You don't have to use the bubble sort as
easier ways to get the same result.
Search WWH ::




Custom Search