11-29-2019 03:29 AM
Hello,
How can I find one letter in a string and when I find this letter turn on a button. I mean, I have made an array of buttons and I insert one string (111222AABABB). Now I want to find if there are any "B" in my string and when I find one "B" I want to turn on automatically one button.
I start doing this program
Solved! Go to Solution.
11-29-2019 03:47 AM
'Match string' is a good function. 😉
/Y
11-29-2019 03:54 AM
But I can´t connect the string and the array of buttons to the function you mention. Because the array of buttons is an indicator.
11-29-2019 04:00 AM
Make an array of Booleans, find the index (indices) of the character, replace the Boolean at those indices in the array of Booleans with a True, put the array in the indicator.
The last part (put the array in the indicator) can be done with a local write.
The first part (make an array of Booleans) can be replaced with a local read (if the indicator has the right size).
And alternative is to simply compare each letter in the string with the character in a for loop. Compare (Is Equal) and auto indexing will get you an array of true\false values. Put it in the indicator.
11-29-2019 04:22 AM
Thank you for your explanations, there have been very helpful. I think is easyer comparing each letter with a character in a for loop, But I don´t know how to do it. Can you help me please?
Sorry I don´t have to much experience in Labview
11-29-2019 04:26 AM
I have done this
11-29-2019 04:32 AM - edited 11-29-2019 04:34 AM
Convert the long string to a byte array (String To Byte Array). Convert the character string to a byte array as well, and get the first element (Index Array).
No need for a loop (sorry about that), simply wire the array and the element to a Equal.
That is somewhat 'hacky' but very efficient.
In a for loop (what you have now) use String Subset to get individual characters. Wire the 'i' to the index and a length of 1.
I'd give both a try, that's a good way to learn!
11-29-2019 04:35 AM
BTW. In your VI "Array" is a control, not an indicator!
So either use a local to set the control value, or change it to an indicator.
11-29-2019 04:40 AM
you mean to do like this?
11-29-2019 05:04 AM
@labview99 wrote:
you mean to do like this?
Getting there. It's simpler than you make it.
On the "B" string, converted to the array, get the first element (Index Array).
The result of the Equal is a Boolean array, so it will fit the Boolean array indicator.