取消
显示结果 
搜索替代 
您的意思是: 

Problem with float and spreadsheet string to array

已解决!
转到解答

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 项奖励
1 条消息(共 15 条)
4,727 次查看

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

2 条消息(共 15 条)
4,697 次查看

@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 项奖励
3 条消息(共 15 条)
4,689 次查看

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 项奖励
4 条消息(共 15 条)
4,685 次查看

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

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 项奖励
5 条消息(共 15 条)
4,682 次查看

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 项奖励
6 条消息(共 15 条)
4,680 次查看

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 项奖励
7 条消息(共 15 条)
4,674 次查看

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

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 项奖励
8 条消息(共 15 条)
4,672 次查看

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 项奖励
9 条消息(共 15 条)
4,663 次查看

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

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 项奖励
10 条消息(共 15 条)
4,652 次查看