Information Technology Reference
In-Depth Information
19. Common statements
In the previous chapter I mentioned that we could finish the delete program for the
account number file and then copy it and do a few modifications in order to get a zip code
delete program. Obviously the latter would be a great deal less complex since we need not
worry about the next number file, although we may want to create a report for the deleted
records. At the same time, in producing the account file delete program we stol e lines
from other programs since the logic was the same for the most part.
There is just one concern in our delete zip code program. We must not delete a zip
code record that is used by any account in our system. If we did wipe out that record, it
would cause read errors on the zip code file, which we certainly don't want. Thus any zip
code must be thoroughly researched to verify that it is obsolete and not still being used by
the system. We trust that the people who give us these zip codes to delete are on the ball.
The deleting of records that shouldn't have been erased is why there may have been
difficulties - which I touched upon earlier - when we shouldn't have problems during
access after having done a successful one.
As you go from program to program there will be many similarities as well as
identical lines of statements. Just think of the structure for the account record and I think
you will agree that it will not change from one program to the next. If it did it meant that
something was drastically awry or else we had to accommodate some new field that was
added. We want the same structure in every program since we are using the same file in
these different programs. When we happen to change the layout of the file, we also want
to make sure that we change it in all the programs that use it. We can help ourselves out
in many cases by using what is referred to as a copy member. This is some member of
another library that consists of lines of code that we are copying into our program. Think
of it as something that doesn't change from program to program, at least not very often.
We create the copy member once and simply include it in the program where it is
to occur by using the keyword
copy .
Before, the beginning of our program was
define account-record structure
account-number integer( 9)
last-name character (18)
first-name character (15)
middle-initial character
street-address character (25)
zip-code integer( 5)
balance signed decimal (6.2)
and with the copy member it becomes
copy acctmemb
where
acctmemb
Search WWH ::




Custom Search