LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array with string to table

Hello folks

Following thin: I have an array with a string. This string contains various values seperated by a ";". Now I want to write these values to a table in LabView so that the user can see the seperated values. But all I've tried failed. Hope anybody can give me a tipp. See also attachement.

Thanks a lot for your help.
0 Kudos
Message 1 of 8
(4,142 Views)
Hi,
I have LV 6.0 so I couldn't open your file, but as far as I've got the problem you need to use "Functions->String->Spreadsheet String to Array.vi". This VI converts the spread sheet string of data separated by some delimiter (";" in you case) to array of these values.
So you have to implement this VI to every string with your values (if you have an array of such strings, then you must do it in the loop). Wire you string to "spreadsheet string" node of the Vi. Then create the string constant ";" and wire it to "delimiter" node. Then create the string constant "%s" and wire it to "format string" node, this means that the output of Vi will be of String type.

See help to this VI for mo details.
The example is attached.

Good Luck.

Oleg Chutko.
Message 2 of 8
(4,142 Views)
The only other thing you might want to check for is to verify that the last character in the input string isn't a delimiter character. If it is, you'll get an extra element in the output array. (Of course, this is only a problem if you make the logical assumption that a delimiter with nothing after it is not a valid value.)

This tends to be a problem the most when you working with a delimiter that is nonprintable--like a space tab or carriage return.

Also note that if the data is in the output format that Oleg shows in his excellent response, LV 2D arrays are rectangular (i.e. there is the same number of columns in every row). Hence, if one string elements has more values in it than the others, LV will pad-out the other rows to match it in length.

Mike.
..

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 8
(4,142 Views)
Thank you Oleg

Your example really helped in anyway!!!
0 Kudos
Message 4 of 8
(4,142 Views)
Thanks Mike for indicating the problems with a table. I will check my code in that way.
0 Kudos
Message 5 of 8
(4,142 Views)
Thanks Mike for indicating the problems with a table. I will check my code in that way.
0 Kudos
Message 6 of 8
(4,142 Views)
In the attached file there is not much done (sure you did not forget something there?), however there is something that looks like a bug; you have wired the N(umber of iterations) of the loop to the element index of the array subset...I'm 99% sure that what you really want to do is wire the i(ndex) to the element index...That would give you the same effect as dropping the subset function and using auto-indexing instead...but anyway.

Attached is a code that might be doing what you want to do. It tries to optimize the conversion by finding the size of the table up-front.
0 Kudos
Message 7 of 8
(4,140 Views)
Thank you Mads for your example. You're right, my VI was not right wired. But the solution of Oleg has solved my problem, because it only was to create a table of a string array with defined length of values for the user to see, what his input was.
0 Kudos
Message 8 of 8
(4,140 Views)