LabVIEW

cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Splitting a string up into an array...

Hello all, I've just started to use LabVIEW as part of my University
project. I have looked all over the place for the information that I
seek but as yet to no avail.

What I wish to do is split a string up into an array and then find out
how many items are in that array.

Say my string is "FOO,BAR"

I have tried to use the 'Scan Strings For Tokens' VI to some success.
It manages to find "FOO" with "," set as the delimiter. How can I
store this in an array and then go back and retrieve the remaining
tokens? The string contains a variable number of tokens.

I think that I could also use the 'Search/Split String' and 'Match
Pattern' VI's to produce the same effect. What is the best way of
tackling my problem?

Hope someone can help as
I've a real headache after tonight...

Regards,

G.

PS- I'll push my luck and ask if anyone could possibly email me
(gibbo_97@yahoo.com) a simple VI that will do this task ๐Ÿ™‚
0 Kudos
Message 1 of 4
(4,917 Views)
"Adrian Gibbons" wrote in message
news:d5d90f23.0212051633.2698add6@posting.google.com...
> Hello all, I've just started to use LabVIEW as part of my University
> project. I have looked all over the place for the information that I
> seek but as yet to no avail.
>
> What I wish to do is split a string up into an array and then find out
> how many items are in that array.
>
> Say my string is "FOO,BAR"
>
> I have tried to use the 'Scan Strings For Tokens' VI to some success.
> It manages to find "FOO" with "," set as the delimiter. How can I
> store this in an array and then go back and retrieve the remaining
> tokens? The string contains a variable number of tokens.
>
> I think that I could also use the 'Search/Split String' and 'Match
> Patte
rn' VI's to produce the same effect. What is the best way of
> tackling my problem?
>
> Hope someone can help as I've a real headache after tonight...

I don't think I understand what you want to do. If we use FOO,BAR as an
example what should be the final result(s)? Would you want an array with
FOO and BAR and a count of 2?
0 Kudos
Message 2 of 4
(4,917 Views)
use the build in function spreadsheet string to array
see attached example.
greetings from the Netherlands
Message 3 of 4
(4,917 Views)
Adrian Gibbons wrote:
>
> What I wish to do is split a string up into an array and then find out
> how many items are in that array.
>
> Say my string is "FOO,BAR"
>
> I have tried to use the 'Scan Strings For Tokens' VI to some success.
> It manages to find "FOO" with "," set as the delimiter. How can I
> store this in an array and then go back and retrieve the remaining
> tokens? The string contains a variable number of tokens.
>
>
> PS- I'll push my luck and ask if anyone could possibly email me
> (gibbo_97@yahoo.com) a simple VI that will do this task ๐Ÿ™‚

Now, you wouldn't want someone to devalue your learning
experience would you ๐Ÿ˜‰

However, try this...

Use a "Spreadsheet string to array" vi. Set the delimeter to comma,
set the format string to %s, use
initialise array to create a 1d string
array(the length is immaterial so set it to 1) and connect this array
to the array type input of the "Spreadsheet string to array vi".

Voila, job done.




--
Remove "spamkill." when replying to this message
0 Kudos
Message 4 of 4
(4,917 Views)