Information Technology Reference
In-Depth Information
to see if it has a value of 0. This means that the read of the file was successful. If it is, the
new line or two indicates what action is to be taken. In this case we have the fields we
need to print a single line of our report. We print that line and then proceed to do another
read. This is accomplished because of the next keyword,
go to ,
which allows us to branch to the label
read-file .
We can now try another read and proceed as before. The keyword
end-if
is used to indicate that our if statement is complete.
The next three lines
if acct-status not = 9
print “the account file is not integral - program ending”
end-if
interrogate or check the value of the field
acct-status
and if it is not equal to 9, there is a problem with the read of the file. In this case we
cannot proceed so we print out an error message. The
end-if
again means that this particular if statement is done. You might say that we should end
the program and that's exactly what will happen since that's the last line of the program.
If the
acct-status
is 9, indicating the end of the file, we will wind up in the same place - exactly what we
want. Note that if the
acct-status
is 0, we won't get to this point since we will have branched back to the label
read-file .
You may be questioning the use of
$$$$,$$9.99
rather than
$$$,$$9.99
for the edited balance. Remember that we need one character for the $ and then one each
for the six digits to the left of the decimal point. That is why we need the six dollar signs
and one 9 or seven places in all. If the balance were $100,000 and we used
$$$,$$9.99
as the mask, the result would be printed as
$0.00
since we have only provided for six positions, but we need seven. As a result, the leftmost
digit would be truncated, which is not what we want. The computer will do exactly what
we tell it to do. It can't correct our omissions, such as this.
The last line of our program
Search WWH ::




Custom Search