cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

2D String array to 2D Numeric array

¡Resuelto!
Ir a solución

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
Mensaje 1 de 12
5.523 Vistas

Sorry, I forget to make the current values default

 

 

0 kudos
Mensaje 2 de 12
5.518 Vistas

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
Mensaje 3 de 12
5.517 Vistas

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
Mensaje 4 de 12
5.502 Vistas

Hey!

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

0 kudos
Mensaje 5 de 12
5.501 Vistas

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

I think the problem ist , and .

How can solve the problem?

 

Zäpfle

0 kudos
Mensaje 6 de 12
5.496 Vistas

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
Mensaje 7 de 12
5.495 Vistas
Solución
Aceptado por el autor del tema zäpfle

Heres a piece of code to replace the separator.

 

Regards,

 

Steve

Stephen C
Applications Engineer
Mensaje 8 de 12
5.490 Vistas

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
Mensaje 9 de 12
5.489 Vistas

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?

 

 

Mensaje 10 de 12
5.483 Vistas