LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D String array to 2D Numeric array

Solved!
Go to solution

Hello everybody,

I would like change a 2D String Array into a 2D Numeric Array. I can't find a solution.

In the attachment is a simple attempt. I tried a lot of other thinks, but without success. 

 

Does anybody know a solution.

 

Many thanks in advance !

 

zäpfle

 

 

LV2010

 

0 Kudos
Message 1 of 12
(4,259 Views)

Sorry, I forget to make the current values default

 

 

0 Kudos
Message 2 of 12
(4,254 Views)

I can't read your vi (only 2009 loaded on this PC), but the easiest way it to wire the 2-d string array to decimal string to number (or Fract/Exp string to number depending on the input and output you want) The output will be a 2-d numeric array.

 

Most of the vi's on the 'String -> String/Number conversion' palette will accept arrays as input, and produce arrays as output, Try it!

 

Rod.

0 Kudos
Message 3 of 12
(4,253 Views)

unfortunely, it doesn't work, I tried the decimal string to number (or Fract/Exp string to number)

 

I attached the vi in LV9.0 or what version do you need?

 

Do you have other ideas?

 

Many Thanks in advance !

 

zäpfle

0 Kudos
Message 4 of 12
(4,238 Views)

Hey!

You can use the "Fract/Exp string to number.vi"

0 Kudos
Message 5 of 12
(4,237 Views)

I did it, but without success (see the attachment).

I think the problem ist , and .

How can solve the problem?

 

Zäpfle

0 Kudos
Message 6 of 12
(4,232 Views)

I think the problem here is the comma (,) in the strings. This will be fine if it is the local fractional separator and you have the use decimal point boolean flag set to false on the "Fract/Exp string to number" VI.

 

You could use 2 nested for loops with a search and replace to switch the comma (,) for a decimal point (.) in the strings, there is probably a better method to search and replace on the entire 2D array at once, but I couldn't spot it in the last few minutes.

 

If you are still having problems with this later, let me know and I will make a samll piece of code to do it.

 

Cheers,

 

Steve

 

 

Stephen C
Applications Engineer
0 Kudos
Message 7 of 12
(4,231 Views)
Solution
Accepted by topic author zäpfle

Heres a piece of code to replace the separator.

 

Regards,

 

Steve

Stephen C
Applications Engineer
Message 8 of 12
(4,226 Views)

Hi Zäpfle,

 

try this:

check.png

(There should be other ways too...)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 12
(4,225 Views)

The conversion DOES work, it's just that it stops at the comma.

 

In decimal string to number that's what the help says it will - I think the function is badly named, it should be INTEGER string to number as only digits, minus sign and leading blanks are allowed.

 

In Fract/exp string to number, I can get the desired result if I change the comma to a period. This is as I would expect n the UK locale. It sees the comma as a character that in invalid in a number, so stops the conversion at that point. As you have the "use system decimal point" input set to TRUE, it should take care of the comma/period problem for you, so check that your system is set to use comma as the decimal separator.

 

Rod.

 

EDIT: I see Gerd has come up with a solution that includes changing the comma to a period. Does this mean that LV has a problem in converting numbers in locales with a comma as the decimal separator?

 

 

Message 10 of 12
(4,219 Views)