LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Minor scan from string bug

I'm afraid we're talking in circles here...


The attached VI fails, as expected. When you wire an integer to the output, the format string defaults to %d. The %d doesn't get "1.0000" only "1", the next %d or %f gets ".0000".


In the attached VI, you should wire "%f %f %f %f %f %f" to the format string, because all the input strings are floats. But it defaults to "%d %d %d %d %f %f".


So for your question: "Won't the Scan from String function give the outputs in the desired formats of integers even though the Inout string is in the format of a float. The context help also suggests the same as what I thought all these days."


It does give the outputs in the desired formats. If you tell it to get an integer, it gets an integer. I can't find any reference that implies otherwise, but I didn't read all the help.


However, if you follow the link "Details", from "Scan From String" it fives the exact problem as an example (input "Red49.4.2", format "Red%d", output "49" remaining string ".4.2".


Regards,


Wiebe.
0 Kudos
Message 21 of 22
(567 Views)
Partha,

I would change your format for saving the data to be honest.  There's no reason to save an integer as a float with 6 decimal places.  It's inefficient at the least.

You can also build a tabs delimiited string for each set of data, append them all together to one large spreadsheet string and then write the file.  There's no-one insiting you rely on an "array to spreadsheet string" function.

You can simply skip this function and create the string yourself.  While you're at it, you can even use the SAME format string to create the string and to scan from it.  An in-built sanity-check.

And as Wiebe has already said, if you (knowingly) save an integer as a float, then you need to read it as a float.  The conversion to integer must be done AFTER scanning from string.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 22 of 22
(563 Views)