Debugging+with+a+variable

Sometimes, a programs refuses to do what you want it to do. It does not give the expected results, or worse, gives no results at all. Sometimes, it ends in an obscure message. To be even more difficult, a program may simply crash without explanation, not all the time, mind you, just enough to frustrate the hell out of you.. Often this inconsiderate program contains many lines of complicated code that display elegant windows.

You know there are no typing errors in your program.You have tried the Debugger, but it doesn't work for you. So there you are : you can't find where the error is. What do you do ?


 * First of all, you comment out the NOMAINWIN so that you can display the information that will eventually lead you to the solution for your problem.
 * Then if you suspect that some code is never executed, you add a :

code format="lb" print "hello there" code

at strategic places in your program. If the "Hello there" appears in you mainwindow, then you know execution went that way.

code format="lb" for i = 1 to totimage print images$(i,1);" ";images$(i,2);" ";images$(i,3) next i code
 * Then you will probably want to test the content of some variables, an array, even a whole file. Exemple :

code format="lb" goto [someplace] code
 * You may even want to skip some code in your program with a

You add all this code just for the purpose of testing your program. Sometimes you need this test code, and sometimes you don't. When you don't, you have to find your test code and delete it. But then, later on, you may need that test code that you've just deteted !

So....to save time and energy, this is what you can do :

At the beginning of your program, add a variable : code format="lb" debug=1 code

Now, whenever you need to add some test code to your program, always do it this way code format="lb" if debug=1 then print "hello there" code

Simple, but it works ! I use it often.