Re: [Flightgear-devel] NASAL error
Nevermind. I found the Nasal docs. - Original Message - From: <[EMAIL PROTECTED]> To: "FlightGear developers discussions" Sent: Thursday, June 09, 2005 4:26 PM Subject: Re: [Flightgear-devel] NASAL error I know this is an incredibly dumb question.. but in Nasal an "elseif" conditon is expressed as "elsif"? - Original Message - From: "Josh Babcock" <[EMAIL PROTECTED]> To: "FlightGear developers discussions" Sent: Thursday, June 09, 2005 3:59 PM Subject: [Flightgear-devel] NASAL error OK, this works great: (other than the fact that it doesn't actually do anything yet) gearLightCheck = func { for (i=0; i<3; i=i+1) { thisProp = "/gear/gear[" ~ i ~ "]/position-norm"; if ( getprop(thisProp) == 1 ) { print("green"); } elsif ( getprop(thisProp) == 0 ) { print("off"); } else { print("red"); } } settimer(gearLightCheck, 5); } but this gearLightCheck = func { for (i=0; i<3; i=i+1) { thisProp = "/gear/gear[" ~ i ~ "]/position-norm"; if ( getprop(thisProp) == 1 ) { print("green"); } elsif ( getprop(thisProp) < 1 ) { < Line 143 print("red"); } else { print("off"); } } settimer(gearLightCheck, 5); } produces this error: Nasal runtime error: nil used in numeric context at /usr/local/share/FlightGear/data/Aircraft/b29/b29.nas, line 143 I know these props are set, because I put the following in the set.xml file: true false 0 0 0 0 As an aside, the initial output looks like this: b29-common.xml initialized 0: red 1: red 2: red 3: red WARNING: Legacy engine definition in YASim configuration file. Please fix. WARNING: Legacy engine definition in YASim configuration file. Please fix. WARNING: Legacy engine definition in YASim configuration file. Please fix. WARNING: Legacy engine definition in YASim configuration file. Please fix. 0: green 1: green 2: green 3: green 0: green 1: green 2: green 3: green Any thoughts? Josh ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] NASAL error
[EMAIL PROTECTED] wrote: > I know this is an incredibly dumb question.. but in Nasal an > "elseif" conditon is expressed as "elsif"? Perl uses "elsif" like Nasal. C and derivatives (and Javascript) use "else if" only because they hack their parser grammers to handle the inherent ambiguity. The bourne shell is a little terser and uses "elif", at the expense of pronouncing the resulting syntax wrong, a bug that Python inherited. So... what on earth is an "elseif"? No language designer in their right mind would choose THAT. :) Seriously: if you're looking for obvious standards here, it's going to be a looong search... One picks ones brain damage and moves on. Andy ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] NASAL error
I know this is an incredibly dumb question.. but in Nasal an "elseif" conditon is expressed as "elsif"? - Original Message - From: "Josh Babcock" <[EMAIL PROTECTED]> To: "FlightGear developers discussions" Sent: Thursday, June 09, 2005 3:59 PM Subject: [Flightgear-devel] NASAL error OK, this works great: (other than the fact that it doesn't actually do anything yet) gearLightCheck = func { for (i=0; i<3; i=i+1) { thisProp = "/gear/gear[" ~ i ~ "]/position-norm"; if ( getprop(thisProp) == 1 ) { print("green"); } elsif ( getprop(thisProp) == 0 ) { print("off"); } else { print("red"); } } settimer(gearLightCheck, 5); } but this gearLightCheck = func { for (i=0; i<3; i=i+1) { thisProp = "/gear/gear[" ~ i ~ "]/position-norm"; if ( getprop(thisProp) == 1 ) { print("green"); } elsif ( getprop(thisProp) < 1 ) { < Line 143 print("red"); } else { print("off"); } } settimer(gearLightCheck, 5); } produces this error: Nasal runtime error: nil used in numeric context at /usr/local/share/FlightGear/data/Aircraft/b29/b29.nas, line 143 I know these props are set, because I put the following in the set.xml file: true false 0 0 0 0 As an aside, the initial output looks like this: b29-common.xml initialized 0: red 1: red 2: red 3: red WARNING: Legacy engine definition in YASim configuration file. Please fix. WARNING: Legacy engine definition in YASim configuration file. Please fix. WARNING: Legacy engine definition in YASim configuration file. Please fix. WARNING: Legacy engine definition in YASim configuration file. Please fix. 0: green 1: green 2: green 3: green 0: green 1: green 2: green 3: green Any thoughts? Josh ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] NASAL error
Josh Babcock wrote: > OK, this works great: (other than the fact that it doesn't actually do > anything yet) > > gearLightCheck = func { > for (i=0; i<3; i=i+1) { > thisProp = "/gear/gear[" ~ i ~ "]/position-norm"; > if ( getprop(thisProp) == 1 ) { > print("green"); > } elsif ( getprop(thisProp) == 0 ) { > print("off"); > } else { > print("red"); > } > } > settimer(gearLightCheck, 5); > } > > but this > > gearLightCheck = func { > for (i=0; i<3; i=i+1) { > thisProp = "/gear/gear[" ~ i ~ "]/position-norm"; > if ( getprop(thisProp) == 1 ) { > print("green"); > } elsif ( getprop(thisProp) < 1 ) { < Line 143 > print("red"); > } else { > print("off"); > } > } > settimer(gearLightCheck, 5); > } > > produces this error: > Nasal runtime error: nil used in numeric context >at /usr/local/share/FlightGear/data/Aircraft/b29/b29.nas, line 143 > > I know these props are set, because I put the following in the set.xml file: > > > >true >false > > 0 > > > 0 > > > 0 > > > 0 > > > > > As an aside, the initial output looks like this: > b29-common.xml initialized > 0: red > 1: red > 2: red > 3: red > WARNING: Legacy engine definition in YASim configuration file. Please fix. > WARNING: Legacy engine definition in YASim configuration file. Please fix. > WARNING: Legacy engine definition in YASim configuration file. Please fix. > WARNING: Legacy engine definition in YASim configuration file. Please fix. > 0: green > 1: green > 2: green > 3: green > 0: green > 1: green > 2: green > 3: green > > Any thoughts? > > Josh > > ___ > Flightgear-devel mailing list > Flightgear-devel@flightgear.org > http://mail.flightgear.org/mailman/listinfo/flightgear-devel > 2f585eeea02e2c79d7b1d8c4963bae2d > Umm, never mind. I was setting /controls/gear/... instead of /gear/... I had the solution a while ago, just typoed it away. Just a case of NASAL starting up before YASim gets a chance to create the node. Mea culpa. Josh ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] NASAL error
Josh Babcock wrote: > OK, this works great: (other than the fact that it doesn't actually do > anything yet) > if ( getprop(thisProp) == 1 ) { > but this > } elsif ( getprop(thisProp) < 1 ) { < Line 143 > produces this error: > Nasal runtime error: nil used in numeric context >at /usr/local/share/FlightGear/data/Aircraft/b29/b29.nas, line 143 Property initialization rules are complicated. You are creating proprties with a type of UNDEFINED from an XML file, which are then being set from within the YASim code using setFloatValue(). Something is producing a nil value when you read it, or perhaps when it is being converted from a string. In general, you should always ready to handle the case where a property is not yet initialized, or is deleted and/or changes type at runtime. As to why your example fails with "<" but works with "==", that is correct behavior. The less-than operator is obviously numeric, and dies if one of the arguments (nil, in this case) cannot be converted to a number. The equality operator is more general, and returns false under those circumstances. It is perfectly legal to compare nil with another object for equality (e.g. if(list.next == nil) { ... }). Can you try to pare the example down to something I can run and reproduce? Andy ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
[Flightgear-devel] NASAL error
OK, this works great: (other than the fact that it doesn't actually do anything yet) gearLightCheck = func { for (i=0; i<3; i=i+1) { thisProp = "/gear/gear[" ~ i ~ "]/position-norm"; if ( getprop(thisProp) == 1 ) { print("green"); } elsif ( getprop(thisProp) == 0 ) { print("off"); } else { print("red"); } } settimer(gearLightCheck, 5); } but this gearLightCheck = func { for (i=0; i<3; i=i+1) { thisProp = "/gear/gear[" ~ i ~ "]/position-norm"; if ( getprop(thisProp) == 1 ) { print("green"); } elsif ( getprop(thisProp) < 1 ) { < Line 143 print("red"); } else { print("off"); } } settimer(gearLightCheck, 5); } produces this error: Nasal runtime error: nil used in numeric context at /usr/local/share/FlightGear/data/Aircraft/b29/b29.nas, line 143 I know these props are set, because I put the following in the set.xml file: true false 0 0 0 0 As an aside, the initial output looks like this: b29-common.xml initialized 0: red 1: red 2: red 3: red WARNING: Legacy engine definition in YASim configuration file. Please fix. WARNING: Legacy engine definition in YASim configuration file. Please fix. WARNING: Legacy engine definition in YASim configuration file. Please fix. WARNING: Legacy engine definition in YASim configuration file. Please fix. 0: green 1: green 2: green 3: green 0: green 1: green 2: green 3: green Any thoughts? Josh ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d