LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting instrument string result to float

Solved!
Go to solution

Hello,

returned string results from an instruments with VISA are always returned with a point.

Depending on the windows installation they must be converted to a value with a comma.

Attachached an snippet of a conversion.

Will this work for all regions? (Using a comma or point)?

 

What is the meaning of the %Le ?

 

Thanks

0 Kudos
Message 1 of 10
(2,957 Views)
Solution
Accepted by topic author OnlyOne

Comma or point makes sense only for string conversion. Numerically across the world, the value does not change. Now, when you convert this number again to a string, at that point you've to tell the string format function to use the local decimal separator.

 

In the snippet you've shared, it looks for a value with a dot separator and converts it into a number. You can understand what each specifier means by double-clicking on the Scan from String function which displays the window as shown below.

santo_13_0-1635345350586.png

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 10
(2,938 Views)

Yes, i want to convert a string to a numeric value.

The string is returned from the instrument and i need it as a numeric value.

Depending on region settings the string 1.23 should be converted to "1,23" or stay on "1.23".

 

What is the meaning of the "L" in the format specifier?

 

Thanks

0 Kudos
Message 3 of 10
(2,930 Views)

A number is a number.  They are represented as bytes in memory and have no format until a human needs to see it.  If you want to display it as something other than what your localization settings tell it to display it as, convert it into a string with that decimal format specifier.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 10
(2,910 Views)

What is the meaning of the "L" in the format specifier?

0 Kudos
Message 5 of 10
(2,851 Views)

Click on the "Help" button to find out.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 10
(2,844 Views)

Help for "Scan Value, format specifier syntax" was not helpful regarding the "L".

0 Kudos
Message 7 of 10
(2,836 Views)

"%Le" conversion code had me stumped as well... and I have been using LabVIEW for a very long time. LV help provides a lot of different values but "%Le" is not one of them.

I had to resort to googling the meaning, and it turns out that it is just a "Long Double". Some archaic C formatting code.

%Le       long double x  (long double)x  

Found it on this page.

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 8 of 10
(2,829 Views)

I cannot find anything on "L" in the help. Is it for "Long?" Is it a unit? LabVIEW does not complain when it's there, but I could not find an effect despite of many attempts.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 9 of 10
(2,826 Views)

@OnlyOne wrote:

Help for "Scan Value, format specifier syntax" was not helpful regarding the "L".


My apologies, OnlyOne.  I had no idea it wasn't available from the dropdown menu (and therefore, not in the help file).  I did not consider that the format specifier was added manually.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 10
(2,812 Views)