LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

format specifier syntax - multiple syntax commands

Solved!
Go to solution

Hey guys,

I know that there has to have been a post on this, but I can seem to find it. I have several (11) DBLs which need to be formatted differently (some are dates MMDDYY, some are values 0.5555) then written to a file. I using <Array to Spreadsheet String> and <Write to Text File> which is why I need to format it. Here's the format specifier syntax I'm using: 

 

%8.0f %4.0f %5.0f %3.1f %5.2f %4.2f %3.1f %3.1f %3.1f %4.4f %3.2f

 

When I open the file, this syntax follows every value (and they aren't formatted). I'm hoping there is a glaring mistake that can be easily fixed!

 

(PS I've tried every different delimiter to no avail)

 

Cheers,

Tyler

 

 

Tyler C. | Certified LabVIEW Associate Developer

0 Kudos
Message 1 of 4
(3,158 Views)
Solution
Accepted by topic author Tyler_C

Hang on to your current code until this idea is (eventually) implemented:

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Separate-Format-String-for-each-index-of-Array-to-Spre...

 

In the meantime you are going to have to individually format the columns to have different formats.

Message 2 of 4
(3,147 Views)

It would help if you upload your code to be certain that we understand what you're doing.  If that is the format string you're passing to "Array to Spreadsheet String" then I think I see the problem - you can only pass a single format specifier to that function, and every value is formatted identically.  Any unused format specifiers are treated as normal text which is why they're showing up in your file.  Unfortunately you need to do a bit more work to make this work right.  One option is to separate out the columns, format them into strings, recombine the columns into an array of strings, and then write that out with "%s" as the format specifier for Array to Spreadsheet String.  Another possibility is to use Format Into String and index out the array elements.

0 Kudos
Message 3 of 4
(3,144 Views)

Thanks Darin, I'll give that a try. Nathan, I had built an array then tried to format. Seems like this will be an easy fix. Format then build the array, the write to text.

 

Cheers,

Tyler

Tyler C. | Certified LabVIEW Associate Developer

0 Kudos
Message 4 of 4
(3,140 Views)