09-26-2017 05:53 AM - edited 09-26-2017 05:55 AM
Hello everyone,
I have a problem with this function. I send data with arduino using VISA, with string format. The problem is: if I send "28,30" there is no problem, it reats 28,30, but if I send "28.30" it reads the value 28,00. I have already tried with %f. %.; and I can`t find a solution. ![]()
Best Regards,
Jose S.
Solved! Go to Solution.
09-26-2017 06:33 AM
09-26-2017 07:31 AM
I'm guessing that you are using the comma (,) as a "decimal separator", i.e. 28,30 means 28-and-30-hundredths (what I would write as 28.30, as I use a period instead of a comma).
By default, LabVIEW should use whatever your PC uses as the default, so the string "28,30 28.30" read with format "%f %f" should give you "28,30" and "28", that is, a 4-digit floating decimal number and a two-digit number, with the period signalling to LabVIEW to stop scanning because a non-floating-point-character (the period) was encountered.
You can set the comma or period (or set "use what the PC uses") by putting the Format code %,; (use comma), %.; (use period, or %; (use system default). Thus if you wanted to read "28,30 28.30" as two floats, and you knew the first used a comma, the second a period, you would specify "%,;%f %.;%f" (you specify the separator before specifying that you want to parse a Float).
You can find this yourself by reading the Help for "Scan from String" and then clicking on the "format string" link in the Help text.
Bob Schor
09-27-2017 06:17 AM
Thank you! very well explained.
Best Regards,
Jose S.