Information Technology Reference
In-Depth Information
The very last keyword is
end ,
which will close the account file and end the program. That is all there is to the program
with the main activity consisting of a read, nine print lines and an end. This program
simply opens and reads the file into an appropriate layout, prints out the nine fields on the
first record, closes the file and ends - truly exciting stuff.
There are a few concerns. For one, what about the rest of the records in the file?
Second, it might be nice to have some labels for the fields on the report so we know what
each is and it may be better for the environment to print the fields across the page rather
than down it. While we are at it, what about a title for the report? Why doesn't the
account balance print with a decimal point and without those leading zeroes? Lastly, why
do the names begin in lower case letters rather than upper case and what would happen if
the account file had no records or didn't exist at all? These are all valid questions, which
need resolving.
Let us begin with the question about upper case in the names. The reason they are
lower case is because someone entered them that way. We can resolve that in one of two
ways by either reminding the data entry people to appropriately use capital letters in these
situations or we could change our data entry program to make sure that these first
characters are upper case on the file no matter what is entered. Needless to say it is
important to enter correct data otherwise our file won't have much validity. You've heard
the expression, “If you put junk in, that's what will eventually come out.”
Before continuing, let me clear up one point relative to upper and lower case. You
may remember that I said we needed only lower case before. And yet how do we account
for the first letter of the name without capital letters? The restriction on using only lower
case applies only to our computer program, not to the data itself. We can certainly get
along well with that limitation. However, we probably need to allow both upper and
lower case in the data that will be on our file.
We could print a label before the account number by the statement:
print “account number: ” account-number
and the output would then be
account number: 391023123
which is an improvement over what we had before. The double quote enables us to print
literals or strings of values that can be helpful in reports. It may be hard to see, but note
that there is a space after the colon, which keeps the label and the actual account number
from running together.
This won't put all the fields on one line but we could do it by two print
statements. The first would print all the field labels and the second would print the actual
field values. Since a line on our report has space for about 130 characters and our record
layout is 99 characters, we should have enough room on one line to print all the fields and
have room for spaces between the fields as separators. This we can do by the following
print lines:
Search WWH ::




Custom Search