Debugging PowerBASIC Programs

Once your code is written, the next step is to test it to make sure it performs according to specifications. Regardless of the computer language used, certain programming errors are common: misspelled or misused variables, inverted logical tests, mistakes in syntax, and "reasonable" tests that cause disastrous failures when unreasonable data is supplied. Each language also has its own common errors, unique because of the peculiarities of its language.

Some of BASIC's unique problems include the free conversion of most numeric data types, side effects of global variables, default data types, and overuse of GOTO causing problems with incorrect branching. These are well known to the experienced BASIC programmer but are not generally found in other languages.

The PowerBASIC Integrated Development Environment (PBEDIT.EXE) can be used to find, and correct, both general programming errors and errors specific to BASIC. Nearly every program has bugs at least at first. To find them, you may need to check any statement in the program, display the value of any variable, and observe the program flow from line to line. PBEDIT has all these capabilities and more.

This section explains how to use PBEDIT to find and fix errors in a sample program, by providing a list of the debugging commands, a description of each, and then showing how each is invoked. If you follow certain guidelines when creating your program, you will find debugging easier (and less necessary). The procedures we describe here will help you form your own set of guidelines that will make your programs easier to write and maintain.


See Also

How the integrated debugger works

The DEBUG Menu

Debugging a simple program

The Integrated Development Environment

Debugger Settings