Debugging by Simulating Breakpoints
by Kevin (maitrikaruna@yahoo.com)

Home

Two Years Ago in LBNews
Effective GUI Design
Alternative to Graphics Printing
Liberty Basic Simple Help
New LB Programming Contest
Debugging by Simulating Breakpoints
Multi-Coloured Text Input Boxes

If you are having problems with your code and need to debug it, in Qbasic or Visual Basic you could set a breakpoint in your code. A breakpoint allowed you to start your program as normal, and when the code reached the line you have selected as a breakpoint, it would automatically stop. At this point, you could print out variable names and\or step line by line through the execution path.

LB does not yet provide a breakpoint option, but with its very useful Debug screen and a line of code, we can accomplish the same effect. If the line of code you want to stop or break on is at the beginning of your program, then simply start the execution of your program with the "Run Debug" option from the menu. Then click on the "step" button to walk line by line through the program until you reach the line in question. Note that the Debug window automatically updates and displays the variable values as you step through each line.

For most code though, this process of stepping through each is too slow and would often take a long time to reach the line in question. In that case, we need to insert a stopping point in the code. So find the point in your program that you would like to start debugging at, and insert the following:

Input breakhere$

Now start the program with "Run Debug" again. This time click the symbol in the debug window for the program to run, not walk or step. When the code reaches the input statement, it will stop and wait for your input. Before responding to the input request, make sure to click the "step" button in the debug window. Now you can press the enter key in your application. Next, return to the debug window begin stepping through the code line by line from this point forward.

Good luck!

Home

Two Years Ago in LBNews
Effective GUI Design
Alternative to Graphics Printing
Liberty Basic Simple Help
New LB Programming Contest
Debugging by Simulating Breakpoints
Multi-Coloured Text Input Boxes