LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to search array of control refs

I have an event case that handles a number of controls of different types in the user interface. I have a global array that holds references to each of several ring controls; I'd like to test whether the control that triggered the event is one of the ring controls.

I can use a while loop, and control the CtlRef for the event to each ref in my global array--that works fine. But it seems that the Search 1D Array operator would be a natural choice, cleaner and likely faster than a while loop. However, I get a type mismatch when I hook the array of ring refs and the incoming CtlRef to the search function. I tried casting to more specific type on the CtlRef--to a ring ref--but that didn't fix it. Any ideas?
0 Kudos
Message 1 of 3
(2,629 Views)


earlevel wrote:

I tried casting to more specific type on the CtlRef--to a ring ref--but that didn't fix it.

You should have gone the other way. When you have an event common to several types of controls, the CtlRef terminal will use the class common to all those controls, so you should cast the references to the more generic class. The cleaner solution, however, is to use the equal node to compare the array of references to the CtlRef terminal and then search the resulting array for T.

___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(2,617 Views)

@tst wrote:

You should have gone the other way. When you have an event common to several types of controls, the CtlRef terminal will use the class common to all those controls, so you should cast the references to the more generic class. The cleaner solution, however, is to use the equal node to compare the array of references to the CtlRef terminal and then search the resulting array for T.





Yes, I did consider that I should be going to more general, but it seemed that I couldn't do that to the array in one shot, so it would have bought me nothing over the sub-optimal solution that already worked. The conversion to the array with the compare node I hadn't considered though, and that's an excellent solution--thank you much 🙂
0 Kudos
Message 3 of 3
(2,610 Views)