I've just added a module with some Nasal debugging helpers. Currently it contains these functions:
debug.dump([<variable>]) ... dumps full contents of variable or
of local variables if none given
debug.backtrace([<comment:string>]} ... writes backtrace with local variables
(similar to gdb's "bt full)
debug.exit() ... exits fgfs
debug.bt ... abbreviation for debug.backtrace
debug.dump() dumps the contents of the given variable to the console. On
Unix/Linux this is done with some syntax coloring. For example, these lines
var as = props.globals.getNode("/velocities/airspeed-kt", 1);
debug.dump(as);
would output
</velocities/airspeed-kt=1.021376474393101 (DOUBLE; T)>
(See first attached image debug1.png for the color version.) The "T" means
that it's a "tied" property. The same letters are used here as in the
property-browser. The angle brackets seem superfluous, but are usefule
because debug.dump() also outputs compound data types, such as vectors and
hashes. For example:
var as = props.globals.getNode("/velocities/airspeed-kt", 1);
var ac = props.globals.getNode("/sim/aircraft", 1);
var nodes = [as, ac];
var hash = { airspeed_node: as, aircraft_name: ac, all_nodes: nodes };
debug.dump(hash);
yields:
{ all_nodes : [ </velocities/airspeed-kt=1.021376474393101 (DOUBLE; T)>,
</sim/aircraft="bo105" (STRING)> ], airspeed_node : </velocities/airspe
ed-kt=1.021376474393101 (DOUBLE; T)>, aircraft_name : </sim/aircraft="bo
105" (STRING)> }
for the colorized version see attachment debug2.png
debug.backtrace() outputs all local variables of the current function
and all parent functions. MS Windows challenged people see no colors.
m.
debug1.png
Description: PNG image
debug2.png
Description: PNG image
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Flightgear-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/flightgear-devel

