Setting and using breakpoints

We know the program did not fail within the first few lines; it requested the name of the input file, and it successfully opened that file.  Therefore, the problem must have been caused by something further along in the code.

The first suspicious line concerns the GetAWord subroutine.  Set a breakpoint at the line reading:

position = INSTR(FirstString$, Blank$)

Use the arrow keys to move to that line.  As you do, you'll notice that the execution bar doesn't move.  That is because you are not executing the program; you are just using the source browser to move within the program source.

To set a breakpoint at the line to which you moved, double-click on it or press the F9 key.  The line is highlighted, indicating that the breakpoint has been set.  If you wanted to remove the breakpoint at that line, double-click on it or press the F9 key again.  The breakpoint highlighting differs from the execution highlighting, and this difference helps you to avoid confusion over highlighted breakpoints and the current program position.

Once more, click on the Run button (or press F5).  TWORD starts running again, and things happen just as before, with one exception: after the first line from the data file has been displayed on the User screen, TWORD halts and waits for further commands.  PowerBASIC has reached the breakpoint.  The caret and the execution bar are on the line containing the breakpoint.

The breakpoint line cannot be doubly highlighted, so the execution bar obscures the breakpoint highlighting until the program executes further.  The program stops each time it reaches the breakpoint line.

You can also stop a program running within the debugger by clicking the Stop button.  When you do this, the program executes the current line and stops at the beginning of the next.  Control is then returned to the PowerBASIC debugger, and the execution bar highlights the next line to be executed.  You may now use debugger commands to step through the program or resume execution.


Next See: Tracing execution


See Also

Debugging PB/Win Programs

How the integrated debugger works

The DEBUG Menu

Debugging a simple program

Debugger Settings