« release excitement | Main | Latest developments at Laszlo Systems »

OpenLaszlo debugging tips from Tucker

The OpenLaszlo debugger has many features that I haven't learned about until recently. The classic println in OpenLaszlo is just

Debug.write("My message, hooray.");

This method is variadic and clever. Comma-separated arguments are printed as "live" debugger objects.

<method name="doSomething" args="x">

Debug.write("This is", this, "and x is", x);


gives you this...

This is #theView and x is 27

See how #theView is blue? That indicates that it is live. Click on the blue text
and the debugger will print (almost) everything it knows about #theView.

lzx> Debug.inspect(#theView)
#theView {
[LzEvent, LzEvent]
_instanceAttrs: «Object#1#3| {id: theView, bgcolor: 2383748, height: 40, width: 40}»
_instanceChildren: «undefined»
addedToParent: true
bgcolor: 2383748
«Function#4| theView_doSomething»
hassetheight: true
hassetwidth: true
height: 40
id: theView
«LzCanvas#5| This is the canvas»
isinited: true
mask: null
nodeLevel: 1
onvisible: #theView.onvisible
parent: «LzCanvas#5| This is the canvas»
width: 40

All of the strings in blue are also clickable; clicking them will print the results of Debug.inspect(it), which may in turn yield more clickalbe, inspectable objects. But this is all kid stuff. Let's get to the power tools. The underscore character is a shortcut for "the last thing the debugger printed," in this case, #theView.

lzx> _
«LzView#0| #theView»

I can call a method on #theView by typing

lzx> _.setAttribute("bgcolor", 0x777777);

and the bgcolor of my view changes immediately.
The last three values the debugger has printed are stored in variables named _, __ and ___.
Up-arrow and down-arrow retrieve this history of commands. Up arrow, return repeats the previous command.

Debug.monitor(who, what) prints out a message each time a particular
property (what) of a particular object (who) changes. Debug.monitor is documented in the developer's guide and is present in 3.1 through 3.4, but not yet present in the DHTML runtime.

And finally, backtracing! Edit the lps.properties file, in $LPS_HOME, to say


then you can call Debug.warn('foo'), Debug.info('foo'), or Debug.debug('foo') in your code and it prints a string which you can click on to see the backtrace from that place. If you use
Debug.trace(<object>, <method name>) or Debug.monitor(<object>, <attribute name>) the messages that those output (at function entry/exit or on modification of an attribute) will include a backtrace too.

(Thanks to Tucker for implementing and explaining these tools.)

Reader Comments (1)

Thanks to Ben for explaining that Tucker has explained them. I'll try to get more of this information into the Legals revision of the Developer's Guide.

-- John Sundman, OpenLaszlo documentation team

9.25.2006 at 09:35 AM | Unregistered CommenterAnonymous

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>