Information Technology Reference
In-Depth Information
The status - which we don't define - can be anything from 0 to 99. This is done by the
keyword
status ,
which is always a two-digit number, or
integer (2) ,
that we will use to verify that any processing of a file has no problems, whether it is a
read, write or delete. Here
acct-status
will be used to see if we have a successful read. A value of 0 will indicate that the read
was error free. In fact we shall see later that other accesses to the file such as a write will
also result in 0, provided they are successful. If we read the file and there are no more
records left, the record status will be 9, indicating we have reached the end of the file.
Any other value that results means that the file has a problem and we can't continue in
our program.
Let's look at the lines
account-number = 9
read-file: readnext acctfile.
The first is an assign statement, where the variable on the left is given the value 9. The
smallest account number is 10, so the
readnext
verb will try to read a record with an account number of 9, but since it can't find
it, it will read the next record. In the second line, the first part
read-file
is a label, which is used since we need to get back here over and over. We could have
called it “xyz” but the name we assigned is much more meaningful. Labels are followed
by a colon.
program-name
was also followed by a colon, but since it is a keyword, it is in bold.
The next six lines work hand in hand.
if acct-status = 0
print account-number “ ” last-name “ ” first-name “ ” middle-initial
“ ” street-address “ ” city “ ” state “ ” zip-code “ ”
( balance, mask ($$$$,$$9.99))
go to read-file
end-if
The keyword
if
gives us the ability to do something depending on a comparison. In this case we are
looking at the field
acct-status
Search WWH ::




Custom Search