Computers for Smart People by Robert S. Swiatek - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Obviously some explanations are in order, so let us start with

            program-name: acctprint.

As you could guess

            program-name

is a keyword that we use to indicate the name of our program. We will be writing many programs so we need to distinguish one from another. We do this with that keyword. The name we choose here for our program is a variable,

            acctprint.

When we write another program we will have some other name and this is needed to keep the programs separate. Note that we choose this name because we are listing account information. It’s a good idea to make your choice meaningful, as that will help you later when you have so many different programs.

            The next few lines should be familiar as they describe the account record and all the fields that make it up. Through the

            structure

keyword we can reference any of our nine fields in the record. We need to do this in order to print them on a report. Note that the end of the structure will be determined by the keyword

            read.

We then have two more keywords,

            read

and

            into

in the line

            read acctfile into account-record.

The variable following

            read

is our account file which has the name

            acctfile,

another variable. This line actually does two things. It opens the file and then reads it into the account record layout, making all the fields available to us so we can put them on a report. Using just

            read acctfile

would accomplish the same result because of the way the file is defined. The keyword

record

ties the field,

account-record

to the account number file so that any read of that file will result in the data being moved to the field,

account-record.

In the world of computers, there are numerous ways of doing things, which can be good and bad. This I pointed out in an earlier chapter when I talked about systems and rules.