LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format Into String: Format String equivalent of Excel's General format?

A silly question, perhaps, but this is the problem facing me:

I need a Format String for the Format Into String VI that behaves like Excel's General format.  Specifically:

1 becomes 1
1.2 becomes 1.2
1.25 becomes 1.25
1.20 becomes 1.2
0 becomes 0

It seems impossible to use some variant of %f that will retain precision when specified, but won't otherwise transform 0 into 0.00.

Am I missing something?
0 Kudos
Message 1 of 4
(8,471 Views)
The answer is %#_6f (where 6 is the maximum number of sig figs) or %#.6f (where 6 is the max number of decimal places)

An easy way to find out a format string you don't know is to use LabVIEW's UI for its controls.  This way you can get instant feedback. So I created a numeric which behaved like you wanted, then right-clicked on it and chose Display Format (Format and Precision in older versions) and got this Window:



Then I click on the Advanced Edit Mode selection to get the format string section where you can doo all sorts of insteresting things with your numerics and timestamps.  Here, the format string can be found and copied.




Message Edited by Matthew Kelton on 02-18-2008 04:48 PM
Download All
Message 2 of 4
(8,468 Views)
Ahh, interesting!

So why is such a useful option missing from the handy Edit Format String UI?

0 Kudos
Message 3 of 4
(8,465 Views)
With the exception of adding Timestamp support, that GUI hasn't really been updated for several versions of LabVIEW.  LabVIEW 7 was the first to give you the capability of hiding trailing 0's in your controls.  I have actually started shying away from using it, as it corrupts special characters (line feeds and carriage returns being the most annoying).
Message 4 of 4
(8,460 Views)