|
Program Debug
The 'Debug' Display
When writing spBasic programs, you may want to step through the statements one at a time in order to debug the program execution. To do this, you use the Debug Controls. To display the debug controls, just click on the D button (second button from the right) of the Edit form. You can also use the "Run/Debug -> Debug Program" menu selection.

The debug display looks like,

To test the Debug mode, first we'll put a 'breakpoint' in the "HelloWorld" program. To put in a breakpoint, put a '*' in front Line 5 (str1 = "Hello "). Make sure the "Debug Mode" checkbox is checked, then press the "Run" button. The program starts at the first statement and stops. Click the Step button two times. The worksheet should now look like this,

Now you can step through the program one statement at a time by pressing the Step button. Tracing through the program shows you how the program operates and allow you to debug it if there is a problem. If you pressed the 'Go' button before you got to the 'breakpoint' in Line 5 (defined by the '*' before the statement), the program would have stopped at Line 5. You can use breakpoints to stop at any line in the program without stepping through the entire program one line at a time.
The Debug Controls

Run Button - This will run the program in the program
window. If the Debug Mode checkbox is checked, the run is stopped at the
first statement in the program. If this is not checked, the 'Run' button
will run the program until a 'Breakpoint' is found or an 'End' statement is reached.
Debug Mode Checkbox - To trace through a program
step-by-step, check the Debug Mode checkbox. Pressing the Run button will
then stop the program at the first statement. If this is not checked,
the 'Run' button will run the program until a 'Breakpoint' is found or
an 'End' statement is reached.
Step Button - This will execute one statement and
then stop at the next statement.
Step Over Button - If the active statement is a subprogram,
this button will execute the subprogram and then 'step over' it and stop
at the next statement in the main program. This is different than the
'Step' button, which would 'step into' the subprogram and execute it one
step at a time. Use the 'Step Over' button when you don't want to debug
subprograms.
Go Button - This button gets out of the Debug mode
and executes the rest of the program until a 'Breakpoint' is found or
an 'End' statement is reached. This behaves the same as pressing the Run
button when the Debug Mode checkbox is unchecked.
Clear Breakpoints Button - A 'Breakpoint' is defined
as a statement with an '*' before it (like in Line 5 above). Programs will stop at a breakpoint if Debug is active.
Pressing the 'Clear Breakpoints' button will clear the breakpoints of
the program displayed in the Edit window. Other programs will not
be affected.
Exit Debug - This exits the Debug Mode.
Variables Button - This button, the right-most button in the top row, appears when the Debug Mode is entered. It displays the Variable List Form which is used to display
variable values as you step through a program. See the Variable List page for an explanation of the Variable List Form.
You can step through a program one statement at a time by pressing the 'Step' button. You can trace through the main program and subprograms, looking at the program flow and watch the variable values change. Pressing the 'Go' button will run the program and stop at a breakpoint. You can exit the run at any time by pressing the 'Exit Debug' button.
|