I have today added/finished two simple features that are interesting for development of Nasal code.
(A) Help->Nasal Console This dialog supports now several tabs, of which each can hold separate Nasal code snippets, all of which are saved on exit and reloaded next time. This is useful for little tests, or for executing code for which writing a key binding is just too much work, such as "props.dump(props.globals)". It's easy to add more "tabs" (= radio buttons). One just needs to add more <code> nodes to autosave.xml. (B) (re)loading Nasal modules at runtime There's a new function debug.load_xml_nasal(), which loads an XML file with embedded Nasal into a nasal namespace. For syntax coloring reasons one may want to use a *.nas extension for this file. Example: $ cat $FG_ROOT/Aircraft/foo/test.nas <PropertyList><script><![CDATA[ # -------------------------------------------------------------- print("hi!"); var hello = func { print("I'm the test.hello() function") } # -------------------------------------------------------------- ]]></script></PropertyList> $ One can now edit this file and import the code into fgfs with this line in a key binding or typed into the Nasal Console dialog: debug.load_xml_nasal("Aircraft/foo/test.nas"); This will load the Nasal code from Aircraft/foo/test.nas into namespace "test" and execute it, so you'll see the message "hi!" on the terminal, and have function "test.hello()" immediately available. You can at runtime change the Nasal file, and import again, etc. And once you are happy with the code, just remove the two XML lines and load the file via classical method. The namespace, to which the code is loaded, is determined from the file name. foo.nas or foo.xml will be added to namespace "foo". The namespace gets created if it didn't exist. Alternatively, one can define a namespace in the file by addind a <module> name: <PropertyList><module>whatever</module><script><![CDATA[ ... ]]></script></PropertyList> m. ------------------------------------------------------------------------- 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 Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel