LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with float and spreadsheet string to array

Solved!
Go to solution

Hello !

 

Naxmouk_0-1594635614703.png

In my project, I receive a string with 3 values who are floats "FirstValue,SecondValue,ThirdValue".

In the output of my VISA Read I can read my 3 values correctly.

But at the output of my spreadsheet string to array I only have integers.

How can I keep my values into float at the output ?

 

Thanks.

0 Kudos
Message 1 of 15
(2,557 Views)

Maybe the values out of VISA Read are using comma as decimal separators. Can you shoew us what the VISA Read string looks like? Try %;%f as a string format, or just try using a tab separator to see if the problem is still there.

 

Ben64

Message 2 of 15
(2,527 Views)

@Naxmouk wrote:

Hello !

 

Naxmouk_0-1594635614703.png

In my project, I receive a string with 3 values who are floats "FirstValue,SecondValue,ThirdValue".

In the output of my VISA Read I can read my 3 values correctly.

But at the output of my spreadsheet string to array I only have integers.

How can I keep my values into float at the output ?

 

Thanks.


I don't understand your question. The output from your Spreadsheet String to Array is a DBL, not an integer. What made you think it was an integer? Is there some odd behavior that you are seeing? Please provide more details. 

0 Kudos
Message 3 of 15
(2,519 Views)

Thank you for attaching your code.  It appears that it works perfectly, as expected.  You didn't attach the vital "piece of the puzzle", the string that you read from VISA.  Suppose you read the three floats, "1, 2, 3" (which are prefectly valid representations of the numbers 1.0000.., 2.0000.., 3.0000).  In fact, try building an Array of Floats and putting the number 1, 2, 3 in it.  Now look at the array -- you will not see any decimal points unless you tell it to display without hiding trailing zeros.

 

Bob Schor

0 Kudos
Message 4 of 15
(2,515 Views)

Your values are definitely floats, as indicated by the orange wire coming out the right. Now if you need them formatted to a specified precision (decimal and zeroes after), you will have to add a little more code as Spreadsheet String to Array is limited in terms of what format strings you can use.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 5 of 15
(2,512 Views)

Thank you for your answer,

 

Naxmouk_0-1594641304025.png

The first 3 values are located after the spreadsheet to array, and the last value is at the output of the VISA read.

My values have "." as decimal separator.

I tried %;%f but it did not worked.

0 Kudos
Message 6 of 15
(2,510 Views)

Hello !

 

Naxmouk_0-1594641473263.png

Before the spreadsheet string to array I had 3 values separated by a comma. 2 of these values were floats, but after the spreadsheet string to array when I want to see my values using an index array I don't have my float anymore.

0 Kudos
Message 7 of 15
(2,504 Views)

The small arrow at the corner of that bottom indicator means there is more to that string than what we can see. Could you copy the whole thing and post it here?

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 8 of 15
(2,502 Views)

Maybe it is your indicators that are configured to display only the integer part. But we cannot know for sure since we can't debug pictures.

 

Ben64

0 Kudos
Message 9 of 15
(2,493 Views)

I believe I know what your problem is. Your localized delimiter is most likely comma, which LV gets straight from the language of your system. So what you will have to do is go through and replace the commas with some other symbol, then replace all your periods with commas, using Search and Replace String.vi. See below.

 

FireFist-Redhawk_0-1594642871694.png

 

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 10 of 15
(2,482 Views)