LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TURN ON ARRAY OF BUTTONS

Solved!
Go to solution

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

0 Kudos
Message 1 of 14
(3,503 Views)

'Match string' is a good function. 😉

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 14
(3,494 Views)

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.

0 Kudos
Message 3 of 14
(3,490 Views)

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.

 

Message 4 of 14
(3,485 Views)

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

0 Kudos
Message 5 of 14
(3,471 Views)

I have done this

0 Kudos
Message 6 of 14
(3,464 Views)

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!

0 Kudos
Message 7 of 14
(3,459 Views)

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.

0 Kudos
Message 8 of 14
(3,452 Views)

you mean to do like this?

0 Kudos
Message 9 of 14
(3,447 Views)
Solution
Accepted by topic author labview99

@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.

Turn On Boolean Array.PNG

Message 10 of 14
(3,439 Views)