Need Script Debugger Tutorial
Sarah
sarahr at genesearch.com.au
Thu Jan 16 21:34:29 EST 2003
As others have said, Rev 2 will have an entirely different debugger,
however I expect some functionality while remain the same and you
probably want information now, so here is a brief explanation:
The 3 popups just allow you to select which handler to debug. The first
selects the stack, the second allows you to select any object that has
a script, and the third allows you to choose a handler.
When you have chosen your handler, click on a line to turn it red -
this is where the debugger will kick in. You can now either click "Send
message" to start that handler running from within the debugger, or
leave the debug window open and do whatever you do to get to that
handler e.g. click a button, type in a field, select a menu item).
When the script gets to your red line, it will stop and wait for you to
tell it what to do next. The difference between step over & step into
only shows up when your handler calls another handler or function.
Suppose you were debugging a script like this:
on mouseUp
put 3 into myVar
put myFunction(myVar) into newVar
answer newVar
end mouseUp
You put the red line on the "put 3 into myVar" line so that is where it
stops. Click "Step over" once - you will see the hilite move one line
down and in the variable list, you will see that myVar is now 3. The
next line to be processed is the one that calls another function.
Clicking "Step over" will show you the result of that function only.
Clicking "Step into" will take you into the separate function so you
can track your way through it as well.
Trace effectively clicks "Step into" about twice a second, so you can
see where your script is going. The Send message button has now become
Run which goes to the next red line (you can have more than one) or to
the end of the handler.
While stopped on a line, you can click on any variable name to see that
variable in the field at the bottom right. From there, you can edit the
variable on the fly. This can be very useful if you have detected an
error, but still want to go on and check the rest of the script.
The other function of the debugger is it's ability to time your
scripts. The debugger slows everything down a lot but the timer at
least gives you an idea of which parts of your scripts are slowing you
down and how many times each line is used. Select your handler as
before but clear any red lines by clicking on them again. Then click
"Start timing", followed by "Send message". The script field will be
divided into 3 columns showing the number of calls to each line and the
taken spent on each line. Click "Stop timing" and "Clear timing" to
revert to the usual display.
A word of warning: the debugger can be so slow with large handlers that
it feels like the program has crashed. There is also no way to button a
handler running although the usual command/control period will usually
work. If you only need to check the value of a couple of variables, you
will often be better off using an "answer" or "put" command to check
them.
Cheers,
Sarah
On Thursday, January 16, 2003, at 09:25 pm, Graham Samuel wrote:
> I have tried to search the usual sources, but I have not found a
> detailed description of the way the Script Debugger works in 1.1.1.
> For example, what do the 'run', 'trace', 'step into' and 'step over'
> buttons do - the last two seem to do the same thing, which is to
> execute the highlighted line of script. What do the other buttons and
> pull-downs do - I have not found out what the pull-down lists are for,
> for example. Why do some steps not get shown, as in some repeat loops,
> etc?
>
> What I'm trying to do is to trace the path thro a quite long program
> in the most intelligent way possible - I already know from a thread of
> last October that there is no path trace as such. I feel that if I
> knew everything the Script Debugger can do, I'd be in a better
> position to work on my scripting problems.
>
> I'd be glad to find I'd missed a tutorial on debugging - if anyone
> knows of one, please say.
>
> TIA
>
> Graham
> --
> -------------------------------------------------------------------
> Graham Samuel / The Living Fossil Co. / UK & France
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list