Information Technology Reference
In-Depth Information
To create a main title for our report we could simply add another print statement.
It might be
print “ Account balance report”
and note the few spaces to the left of the word Account we used to guarantee that the
heading is centered on the page. We shall talk more about headings in another discussion
but now we must accommodate those other records on the file that we didn't list on the
report and the possibility of an empty file or none at all.
We do this by introducing more keywords,
status ,
if ,
go to
and
end-if .
We do have three possibilities here, that is we could have a normal account file or an
empty one or none at all so the keyword
status
will enable us to see which of the three comes into play in our program. The last three
keywords will give us the ability to make decisions and even branch if necessary, which
we will need to do in many cases. The main logic of our program (the code after the
structure and its definition) now is:
define acct-status status acctfile
print “ Account Balance Report”
print “account # last name first name mi street address ”
“city state zip balance”
account-number = 9
read-file: readnext acctfile
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
if acct-status not = 9
print “the account file is not integral - program ending”
end-if
end-program: end
The first line
define acct-status status acctfile
defines a two position numeric field for
acct-status
which refers only to the file
acctfile .
Search WWH ::




Custom Search