There is an interactive debugger built into Turbo Pascal. It allows you to see how the program is changing the boxes as it moves along through your code.
The first five steps are similar to what you did above.
1. Now type "TP6" which will bring up the integrated Turbo Pascal
environment.
2. Press the "F3" key. The Fn keys will either be on the left
side of your keyboard or on top.
You should see a menu that says "Open a File" pop up.
3. Type the name of your program in the place marked "Name"
Press the carriage return key. This will be either a new name
if you are starting a new program or a name that already
exists if you are editing a program you have worked on
previously. The computer will assume that your program ends
with ".PAS" as the extension if you don't specify one. That's
OK for now as we are creating a PASCAL program which must end
with a ".PAS" extension.
4. Type in your program. You can edit by using the arrow keys to
move the cursor around. We can find these on the right. You
can press "Del" to get rid of a character.
(There are a lot more editing capabilities, but that's all you
need to earn an A in this class.)
5. Press the F9 key.
(Again, you may have some syntax errors.)
6. There are four things you can do in the debugger:
a. set a breakpoint, a place in the code where the computer
will stop and allow you to look at things
b. step to the next line.
c. set a watch window which will display a set of variables.
d. just display a variable.
To do a, move the cursor to the line at which you want the break
point. Then press the CTRL and F8 keys simultaneously. The
statement will be in white on a red line. You may want to set more
than one breakpoint.
To do c, add a watch,
press CTRL and F7 simultaneously.
A window saying "Add Watch" will come up. Enter the variable you
want to examine. It will display the variable near the cursor as
you may want to "watch" it. Then press the RETURN key.
You may type in additional variable names here. When you are finished, press the ALT and W keys simultaneously. Then press the T key.
Press the F6 key to get back to your program.
7. After you have entered any breakpoints and watch windows, you
can then press CTRL and F9 simultaneously to run your program.
You will stop at each breakpoint. Press CTRL and F9
simultaneously to go to the next breakpoint. You can set
additional breakpoints or watches after each breakpoint, if
desired.
8. After viewing your breakpoints and windows, you can start back
at the beginning of your programming by press CTRL and F2
simultaneously.
9. There is one more way to debug, one can step through the
program. This is done by pressing F7 to go to each line
successively. If you had set watches, you will see the
variables change.
10. When you are finished, press the F2 key.
17. Press the ALT and the X key.
There is another thing you can do at any break point, that is look
at the value of a variable, i.e., find out what Pascal put into the
box. You may also want to do this as you step through a program
with the F7 key.
To do this:
1. Press CTRL and F4 simultaneously.
2. You will see a window labled "Evaluate and Modify"
Type the name of the variable you want to look at in the top
box--you may already find it there in which case you don't do
anything for this step.
3. Press the Return key.
The value will be put in the result field. Note that this is
the value before the statement upon which the cursor sits is
executed.
4. Press the ESC key to remove the screen.
KEY COMMANDS
F9 - compile but do not run program
CTRL-F8 - set break point
CTRL-F7 - add watch
ALT-W then T - tile window
F6 - next window
CTRL-F2 - reset running of your program
CTRL-F4- view (or modify) variables