Information Technology Reference
In-Depth Information
end-program: print skip (2)
print error-msg
end
You will note that this is a great deal easier than the bubble sort records we used
in the last chapter. I also made a few other modifications to handle sort or read problems.
A new keyword here is what you might expect,
sort .
You might say it magically sorts the account number file in ascending order by the four
fields, zip code, last name, first name and middle initial - in that order - into a new file,
sortfile.
Each of these two lines,
define file acctfile record account-record status acct-status structure
and
define file sortfile record sorted-record status sort-status key account-number structure
spells out the record layout, status and structure, enabling the
sort
to work in the proper manner. The keyword,
ascending
leaves the records sorted from lowest order to highest by those four fields in the way
requested. To obtain the data starting from the bottom of the alphabet, you would use the
keyword,
descending .
From the sorted file, we just produce the report as before. Since there could be
problems with the sort or the read, we have provided for each of those, which you can see
at the sort and read procedures respectively. If there is a problem with the printing of the
report, it's time for a new computer. Are you glad that we don't need that bubble sort?
Now let us see how we can take advantage of these ideas in the real world. We
deal with a program or two that can be helpful in ordering goods in the grocery store, with
little intervention on the part of any human being. We will not actually do the
programming but merely indicate what could be done to have orders for stock
automatically placed.
The front of the store already has an automated system for pricing of groceries and
producing totals for the customer to pay for the goods purchased. This involves scanning
the product to get a price for the item. The system works well but we shall now add an
online program to the process. This will trigger ordering of cases of soup, pickles, cereal
or whatever else is needed to guarantee that we don't run out of stock for a particular
product. To illustrate what will be done, I will deal with one product alone, dill pickle
relish. Of course the procedure will work for any item in the store.
When the jar of relish is scanned at the register, besides the normal routine, an
online program will be running which will add 1 (or 2 if that many jars of the relish are
purchased) to a counter. This counter represents the number of jars of dill pickle relish
that could be added to completely fill the space on the shelf that this product occupies.
Search WWH ::




Custom Search