09-20-2011 04:57 AM
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
Solved! Go to Solution.
09-20-2011 05:09 AM
Sorry, I forget to make the current values default
09-20-2011 05:23 AM - edited 09-20-2011 05:24 AM
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.
09-20-2011 05:50 AM
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
09-20-2011 05:50 AM
Hey!
You can use the "Fract/Exp string to number.vi"
09-20-2011 05:58 AM
I did it, but without success (see the attachment).
I think the problem ist , and .
How can solve the problem?
Zäpfle
09-20-2011 05:58 AM
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
09-20-2011 06:03 AM
Heres a piece of code to replace the separator.
Regards,
Steve
09-20-2011 06:04 AM
09-20-2011 06:14 AM - edited 09-20-2011 06:20 AM
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?