Liberty BASIC Help Online

Lite Debug
"Lite Debug" is an option available in the "Run" menu.  When run with Lite Debug, a program will run as usual and you will not see the Debug window.  If the program encounters an error during execution, the Debug window will pop up with the problem line of code highlighted!  This incredibly handy feature allows you to isolate errors quickly.
 
Lite Debug in Action
To see it in action, type the following code into the Liberty BASIC editor:
 
for x = 10 to 0 step -1
    print 10/x
next x
 
Now, choose "Lite Debug" from the RUN menu.  The program will run normally at first, and print the following in the main window:
 
1
1.11111111
1.25
1.42857143
1.66666667
2
2.5
3.33333333
5
10
 
When the value of x gets to "0", the program halts with an error. The Debug window will pop up with the title, "Debugging - a ZeroDivide".  The problem line of code will be highlighted in the code pane of the debugger:
 
    print 10/x
 
A quick check of the variable list in the top pane shows that x is equal to 0.   Substituting the value of x in the highlighted line of code, shows that it is:
 
    print 10/0
 
It is not possible to divide by 0, so the expression "10 / 0" has caused the program to stop running.   You now know that you can fix the problem by preventing the value of x from reaching 0 by changing the loop target from "0" to "1":
 
for x = 10 to 1 step -1
    print 10/x
next x
 
Running the corrected code by choosing Lite Debug, will cause the program to run, and since there is no longer an error, the Debug window will not pop up.  The main window will display the following results and the program will terminate without an error.
 
1
1.11111111
1.25
1.42857143
1.66666667
2
2.5
3.33333333
5
10
 


Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/