Board index FlightGear Development Nasal

Best debugging strategy?

Nasal is the scripting language of FlightGear.

Best debugging strategy?

Postby c.harms » Tue Aug 24, 2010 11:47 am

Hey everybody!

At the moment, when I write Nasal scripts, my debugging goes like:

  1. Change something in the script.
  2. Write some debugging output into the script, using "print()".
  3. Startup FlightGear (of course my script resides inside the "data/Nasal" directory).
  4. Watch the console during FG startup to see what my script's output is.

So, because of step (3), this is pretty time-consuming, since _all_ scripts get loaded and run during FG startup and, of course, because the whole program starts. Seems to me that this is a bit too much effort when you only want to debug one script.

Is there a better way that I do not see? I thought about getting the Nasal compiler from plausible.org, but then I thought that it probarbly will not know all the FG-specific Nasal stuff, right? So, what is your Nasal debugging strategy?

harms

PS: I know of a .vim-File for Nasal syntax highlighting for the Vim-editor. Has anyone heard of something similar for Notepad++?
User avatar
c.harms
 
Posts: 16
Joined: Fri Jul 02, 2010 9:12 am
Location: Kassel, Germany
IRC name: c_harms
Version: 2

Re: Best debugging strategy?

Postby i4dnf » Tue Aug 24, 2010 12:04 pm

c.harms wrote:PS: I know of a .vim-File for Nasal syntax highlighting for the Vim-editor. Has anyone heard of something similar for Notepad++?


You could try and start from editing the javascript highlighting.. (as they are pretty similar) .. at least that's what I did for kate/kwrite.
i4dnf
Retired
 
Posts: 745
Joined: Wed Sep 09, 2009 7:17 am
Location: LRBS
Callsign: YR-I4D
Version: GIT
OS: Gentoo Linux ~amd64

Re: Best debugging strategy?

Postby Thorsten » Tue Aug 24, 2010 12:43 pm

In some situations, you can actually set parameters from the Nasal console in the menu and call functions from there - dependent on how you script is set up - but that's basically for testing the response to parameters, i.e. a rather peculiar situation in debugging.

In general, a script for Flightgear would usually need the whole environment, i.e. a property tree filled with realistic values and so on to work properly. Often in more complex situations, timing of tasks is an issue. So my debugging goes pretty much as yours - start Flightgear and watch the console, repeat until script works. It scales all the way up to 10.000 lines (so far) :D Most of the time debugging is usually spent in thinking through the system and trying to figure out what goes wrong, so the time spent to start the Flightgear environment becomes a small correction anyway.

I usually do this with the ufo as aircraft and for a lonely airport in the ocean such that no time is gone loading any scenery or aircraft info - this helps.
Thorsten
 
Posts: 11720
Joined: Mon Nov 02, 2009 8:33 am

Re: Best debugging strategy?

Postby c.harms » Tue Aug 24, 2010 1:19 pm

Thorsten wrote:I usually do this with the ufo as aircraft and for a lonely airport in the ocean such that no time is gone loading any scenery or aircraft info - this helps.

That's actually a good advice, thanks!
User avatar
c.harms
 
Posts: 16
Joined: Fri Jul 02, 2010 9:12 am
Location: Kassel, Germany
IRC name: c_harms
Version: 2

Re: Best debugging strategy?

Postby c.harms » Tue Aug 24, 2010 1:28 pm

i4dnf wrote:You could try and start from editing the javascript highlighting.. (as they are pretty similar) .. at least that's what I did for kate/kwrite.


OK, I just started to wirte syntax highlighting for nasal in Notepad++. Of course, it's not complete yet, so everyone should feel free to try it and send me corrections:

Download nasal.xml from my public DropBox folder
User avatar
c.harms
 
Posts: 16
Joined: Fri Jul 02, 2010 9:12 am
Location: Kassel, Germany
IRC name: c_harms
Version: 2

Re: Best debugging strategy?

Postby Jester » Fri Aug 27, 2010 2:22 pm

Also, you can reload individual nasal files into a running FG instance.
Jester
 
Posts: 1200
Joined: Wed Feb 28, 2007 3:53 pm
Location: Hungary
Callsign: BA996,Rescue1
IRC name: Jester01
Version: GIT
OS: Debian Linux

Re: Best debugging strategy?

Postby Hooray » Mon Sep 06, 2010 8:37 pm

c.harms wrote:
i4dnf wrote:You could try and start from editing the javascript highlighting.. (as they are pretty similar) .. at least that's what I did for kate/kwrite.


OK, I just started to wirte syntax highlighting for nasal in Notepad++. Of course, it's not complete yet, so everyone should feel free to try it and send me corrections:

Download nasal.xml from my public DropBox folder


I would ask someone to commit this to the repository, so that it can be easily downloaded and maintained by other users.

Jester wrote:Also, you can reload individual nasal files into a running FG instance.


"Reload"? Sort of, but that will not really work properly if the code in question is running already (i.e. hot code swapping).
Some time ago we actually tried that, and it would not work.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11923
Joined: Tue Mar 25, 2008 8:40 am

Re: Best debugging strategy?

Postby Gijs » Wed Sep 08, 2010 8:57 pm

c.harms wrote:OK, I just started to wirte syntax highlighting for nasal in Notepad++.

Sounds nice, but how do I install it? I've tried the Notepad wiki, but didn't really find a drop-and-go option...
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9447
Joined: Tue Jul 03, 2007 2:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Best debugging strategy?

Postby HHS » Wed Sep 08, 2010 9:04 pm

I use SciTe and syntax highlighting works perfect with nasal!
Up, up and away
User avatar
HHS
Retired
 
Posts: 3624
Joined: Thu Jul 19, 2007 8:09 am
Version: GIT

Re: Best debugging strategy?

Postby Gijs » Tue Sep 14, 2010 7:50 pm

Gijs, 08 Sep wrote:Sounds nice, but how do I install it? I've tried the Notepad wiki, but didn't really find a drop-and-go option...

Anyone?
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9447
Joined: Tue Jul 03, 2007 2:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Best debugging strategy?

Postby Hooray » Tue Sep 14, 2010 9:15 pm

Gijs wrote:
Gijs, 08 Sep wrote:Sounds nice, but how do I install it? I've tried the Notepad wiki, but didn't really find a drop-and-go option...

Anyone?

http://superuser.com/questions/62474/no ... ook-for-it


I can check my windows machine, I also used to have another Nasal syntax file for Notepad++
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11923
Joined: Tue Mar 25, 2008 8:40 am

Re: Best debugging strategy?

Postby Gijs » Wed Sep 15, 2010 1:53 pm

Thanks, it works perfectly!
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9447
Joined: Tue Jul 03, 2007 2:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10


Return to Nasal

Who is online

Users browsing this forum: No registered users and 0 guests