On Tue, 04 Sep 2007 09:10:02 -0700
Andy Ross <[EMAIL PROTECTED]> wrote:
> Syd&Sandy wrote:
> > Hi all , is there a way to format a double and output that to a
> > string property with writing the double to a property first . Should
> > be doable but it escapes me at the moment ...
> >
> > Example : (double) 2.30 to (string) 2:30
>
> Nasal numbers will convert directly to strings according to fairly
> standard representations. Just use them directly, no conversion is
> neccessary:
>
> var val = 2.3;
> var msg = "The value of 'val' is: " ~ val;
>
> If you need fancy formatting, like for example limiting the output
> precision, there is a sprintf() function available that works just
> like the ANSI one:
>
> var msg = sprintf("The value of 'val' is: %.2f", val);
>
> I'm not sure if the colon in "2:30" is a typo or not, but that's
> possible too with a bit of work:
>
> var frac = math.mod(val, 1);
> sprintf("Formatted: %d:%2.2d", val-frac, 100*frac);
>
> Andy
>
Thanks Andy ,
No its not a typo , I want a single string property to hold groundspeed ,TTG
and ET , depending on which mode is selected for display on the Primus PFD....
I didn't know about the sprintf in nasal , sounds perfect for the job :)
Cheers
--
Syd&Sandy <[EMAIL PROTECTED]>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel