Use of the Debugger ?

J. Landman Gay jacque at hyperactivesw.com
Thu Apr 27 13:52:59 EDT 2006


Francis Nugent Dixon wrote:
> Hi from Paris,
> 
> To continue after Jaqueline's and Richard's comments.
> 
> Interesting subject. Maybe we could ask other people
> if they use the debugger ?
> 
>> Richard Gaskin wrote:
>>
>> My first reaction is to pick my jaw up off the floor. How
>> can you not use the debugger much? I *live* in the
>> debugger!  Who can program without a debugger?
>> You are making more work for yourself, I think.
> 
> I used HC every day for more than 10 years, and now
> I use Revolution every day. I never used HC debugging,
> and I haven't even thought about Revolution debugging !
> I don't even know how it works.

I think it would be valuable for you to learn, because everything you 
describe below is done automatically for you in the debugger.

> One thing I have found very useful. I declare globals
> for every local, during testing, and then comment out
> the global definitions after testing. They will be available
> in the future, if I make any major mods to my scripts.

The Variable Watcher shows local variable values automatically when you 
are in debugging mode. You don't have to specially declare them or turn 
them into globals.

> I use the "do" command often, but in the form :
> 
>          put xxxxxxxxxxxx into DoIt  -- DoIt is a global
>         do DoIt
> 
> Then I can see if I blew it !
> 
> I have a header card on my stacks (which I build
> from pre-prepared models). I have displayglobals,
> displayfields and displaybuttons functions available
> in all my stacks, to see what I have defined. I often
> code "exit xxx" in my scripts during testing, and comment
> them out as I go. My only gripe is that the Variable Watcher
> doesn't update in real-time. You have to close it and
> open it again, each time. But then, I am just about to
> create a button to do this ........... !

The VW will update automatically if you have "Script debug mode" turned 
on in the Development menu, and you are in the process of debugging a 
script.

If you are not in the process of debugging, the VW will show the values 
of all global variables. They will update in real time, but sometimes 
you need to click on them to update the display. If you are debugging a 
handler, all variables update dynamically (without clicking.)

Try it, I think you will be amazed at the amount of information you can 
get. Do this:

Open a script you want to debug. Make sure "Script debug mode" is 
checked in the Development menu. Click in the column to the left of any 
line in the handler where you want to see what is happening. This sets a 
red dot there, which is a breakpoint. Open the variable watcher.

Now, in your stack, do whatever action is required to run that handler. 
The place where you have put the breakpoint (the red dot) is where the 
script will stop. Look at the variable watcher -- all your variables are 
there with their current values. Use the buttons at the bottom of the 
script window to step through (or step over) each line of script. The 
variable watcher values will change. If you don't want to click the 
buttons, you can step into each line by pressing the spacebar. You can 
step over each line by pressing Shift-spacebar.

If you want to test what a different value would do to your handler, you 
can change it inside the VW while you are debugging. Click a line in the 
VW, and you will see the value of that variable in the bottom pane. You 
can change that value to whatever you want. Hit the Enter key to put the 
new value into the variable. Then continue stepping through your script, 
and it will use the new value you put in instead of the original value.

I sometimes use this technique to test what will happen if my stack 
encounters bad data; for example, I make a variable empty to see how my 
handler will work in that situation. Or I make a numerical value into an 
alpha value to see what will happen. It is a good way to test out 
various situations.

There is more you can do, but that's the important stuff. Try it, I 
think it will save you some time.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list