Information Technology Reference
In-Depth Information
8. Program flow and compiles
So far the two programs tha t have been discussed have taken an input file and
produced output. In each case the input was the account file and the output was a report,
even though one was paper and the other was on the screen. We still have to deal with
updating a file, but once we do that, we will have covered every possible scenario as to
what a computer program can do. We won't get to the update feature for some time but
right now let me summarize the way computer programs process line of code.
A computer program will execute one statement after another until finally it hits
the end. In our P language, that happens to be the
end
keyword. It can get to different places because of branches to labels, triggered by
go to
statements. These can be conditional, that is based on an
if
statement, but they could also be unconditional. The latter would be seen if we had a
group of print statements followed by a
go to
which did not have any
if
statement preceding it. Consider the following statements:
If file-switch = 0
go to next-step
end-if
go to start-read
screen (1,7) “file switch: ” file-switch
The second
go to
statement is an unconditional branch. Note that the next statement can never be executed
because of this
go to
statement. Let's look at another set of statements:
If file-switch = 0
go to next-step
else
go to start-read
end-if
screen (1,7) “file switch: ” file-switch
The field
file-switch
Search WWH ::




Custom Search