Information Technology Reference
In-Depth Information
go to start
end-program: end
which I prefer since it's fewer lines of code.
We don't want any program to loop indefinitely. You may ask if there is some
way to check the lines of the program before we actually run it. There certainly is. There
are two possibilities for this. In the P language as in a few others, we write the program
and then simply try to run it. If things are in order, all the fields are properly defined,
every
if
statement has a matching
end-if ,
each left parenthesis is matched by a corresponding right parenthesis and so on, then the
program will do what it should. Well it may not do exactly what we want but at least it
won't abend and we will have made some progress.
On the other hand, if something is amiss such as an undefined field, then the
program will try to run and pause because of that deficiency. At that point there will be
some message indicating more or less what went wrong - at least in most languages. If
the warning is not specific enough it may list the line with the problem and you can
somehow figure out what's wrong, change it and continue to run the program. Of course
there could be another different problem and once again you would have the same
situation. You could correct it and resume the program and eventually get to the end.
Any program that we write is referred to as source code. Whether the running of
the program proceeds as above or in one other manner, it will still be a source program.
The other possibility is that we will need to compile the program or source code. This
process is nothing more than running the program through a compiler to find out if there
are any errors such as we mentioned above. If there are problems, we will get a list of the
trouble spots and we can change the code and then recompile the program. Once all the
errors are cleared up, the compiler will create what is referred to as object code. This is
what is actually executed when we run the program, at least if we compile the source
code. If you were to try to view some object code it would probably look like obscenities.
However, this is what the computer needs to run your program and object code is
sometimes called machine code for that reason.
As far as compiling a program, it sounds complicated but it is just running your
source code through another computer program to create object code or find basic
program problems. With the P language we don't have to worry about that process but we
still need to take care of these errors when we run the program, provided there are
oversights in the code. When you get to work with other people in a programming
environment and you need to do a compile, you will be given enough information to
proceed.
At this point you may think that you are home free if your program compiles and
then runs to completion. Maybe so, but there could be logic problems. When you design a
program you have a good idea what you want done so you code accordingly. The
computer then follows your directions but if you unknowingly have the wrong code, the
Search WWH ::




Custom Search