Information Technology Reference
In-Depth Information
file ,
which we should have had in the earlier programs. It lets us know that we are defining a
file. The file status is also included in our definition of the file - we don't need another
line for that, though we could have had a separate definition of it - and so are the record
layout or structure, and the key of the file, since we are inquiring on the account. As
mentioned earlier, all the files in our system are indexed files, so we'll read them with a
keyed read, even if we process the file one record at a time.
We clear the screen, but only once, and print the title on line 1 in column 30,
followed by all the other headings on the appropriate lines. The next line introduces a
new keyword:
input-number: input (4,36) account-number
giving the person at the screen the chance to enter a nine-digit account number. The
keyword
input
halts all activity until something is entered. If there is input, we clear the error message at
the bottom of the screen if one is displayed. It was on the screen a sufficient amount of
time. This is necessary for two reasons: first, we need to give the person entering data a
chance to look things over; second, it's impossible to read the screen if the data is erased
too fast. This reminds me of one of my college professors who wrote with one hand and
erased what he wrote with the other - not my idea of a good teacher. When it comes to
important messages at the bottom of the screen, a good practice is to leave the error
message on the screen until something is input. We have defined
account-number
as a nine-digit integer and whatever is entered to the right of the literal
account number:
has to be a number from 0 to 999999999. If it is, the account number file can be read.
You will note that entry for the account number begins at position 36 in row number 4
but if we had omitted the (4,36), it would start in the position right after the colon
following the literal. This mention of the specific row and column allows for a space.
You will not be able to enter letters of the alphabet or any special characters into
the input field. If you enter 9 for the account number, you would not need to key the
leading zeros, since that one digit would suffice. The next line is a decision, which allows
the user to end the program, which is done by entering 0 for the account number. Zero is
certainly an integer but not a valid account number. As we have pointed out, account
numbers have to be greater than 9. Entering 0 terminates the program and forces a branch
to the label
end-program
which ends all activity. The next statement
read acctfile key account-number
should be familiar. The only difference involves the keyword
key .
This statement takes the value that was entered for the account number, and uses it as a
key to read the account file into the structure. The statement could be replaced with
read acctfile
Search WWH ::




Custom Search