02-04-2011 10:34 AM
Hello,
I'm building a front panel with, say, a bunch of buttons/indicators contained in two clusters. Inside a while loop, I got an event structure with two cases, one for each cluster, waiting for a value change of either cluster. I figure out which button was pressed by comparing OldVal and NewVal.
Now, I want to generalize the comparison to a SubVI since I will be adding loads of button clusters soon. The SubVI I managed to come up with now returns me a string containing the name of the control which changed its value.
However my SubVI only accepts a single kind of clusters and isn't generalizable. I understand this can't even be done directly and I have to use control references to pass inside to my SubVI. But I can't create control references for both OldVal and NewVal clusters, only one for the control on the front panel.
So, how do I create a SubVI which returns me a string containing the name of the control with a different value between two identical clusters of any type, inside an event structure?
My LV version is 7.0 and I can't open most of the attachments on this forum, so I'd appreciate screenshot solutions.
Solved! Go to Solution.
02-06-2011 07:17 AM
You should consider whether you actually want to move this to a subVI. I can't say I understand exactly what you're planning on doing, but you probably can (and should) do it all in the main VI.
In any case, you can use the Controls[] property to get a reference to all the controls inside the cluster and register an event for the control directly (as opposed to the cluster). All the code here should be doable in 7.0, but again, I would advise that you just do it in the main VI:
02-09-2011 03:19 AM
Thanks for the advice. I'm not that familiar yet with dynamic events but your solution looks fairly understandable, so I'll have a look at them now.
My stuff is doable in the main VI as well, but I will end up using ten or so pieces of the same code, so I'd like to go for a subVI.
What I am trying to do is to monitor front panel input control changes. The controls are arranged in clusters and once something changes, I figure out what changed and deliver the new setting values for my signal generators etc.
02-09-2011 03:30 AM
Here you can code like this so that you will come to know which button has been pressed.
02-09-2011 04:35 AM
This approach worked! However instead of the for loop I use a not equal comparison for the two clusters and search the resulting 1D array for a True value. But now I've got a subVI with a boolean array and a CtlRef as inputs and a string as output.
Many thanks to both of you!
Lauri
02-11-2011 03:00 AM
A little update: Using the solutions above proved fruitful once I figured out how to make the cluster reference more generic, i.e., deselecting the [ ] include data type flag on the context menu. The option was grayed out before I dragged a cluster control to the reference control in the front panel.