08-31-2009 09:06 AM - edited 08-31-2009 09:08 AM
Hello,
I want to make a suggestion.
I often want to use 2 or more controls to trigger the same event, because sometimes the code for one control is only slightly different then for the other control. An example of this is a motor that turns left when a positive speed is entered and right when an negative speed is entered (See Example 1). To make sure my code will stay simple to read, I can easily "group" them in this manner (as in not coding 100 nearly the same events).
Please keep in mind that these are simple examples. For my coding I have to do more then just entering a constant. I have to do complex calculations for one control, maybe read a sensor for another and do nothing for a third. So here it is mustly not possible to use sub-VI's.
My suggestion is to make it possible to wire the control-reference from the event structure to a case-structure (See Example 2). This is not possible at the time. I managed program a decoder to find out what control was activated. But it feels dirty and takes away a lot of space. Being lazy, it would be great if NI could make it so that the Case-Structure would automaticly list all possible control-references.
Hope you guys understand what I mean. Study the 2 examples, I think they will make it clear.
Thank you.
Regards,
Heinen
08-31-2009 09:14 AM
An option is to read the label of the control, this should never change.l
Another option is to create an array of references and do a 'find in array' the returned index tells you which control was used.
Ton
08-31-2009 09:16 AM
A better solution for the case on the right would be to create an array of the releveant references outside the loop and then use search array with the output index wired to the case structure.
Wiring a control reference to a case structure is an interesting idea, but I have not really thought about it in detail. Maybe you can post it as a new idea over in the LabVIEW Idea Exchange.
08-31-2009 05:33 PM
05-06-2020 01:18 PM
I running into the same issue now and then, but had a different solution in mind. With this idea you would get a cluster or an array of booleans for your example, which you could convert to a number and wire to the case structure. Would be grateful to hear your thought on this:
05-06-2020 05:40 PM
Just put the buttons in a Radio Buttons cluster that allows No Selection. Then do this:
05-06-2020 06:12 PM
I love the radio button! But it has the limitation that it groups your buttons together on the front panel. You lose the ability to place them anywhere.
05-07-2020 06:54 AM
@mike-o-tronic wrote:
I love the radio button! But it has the limitation that it groups your buttons together on the front panel. You lose the ability to place them anywhere.
Well then try nested event structures:
05-07-2020 08:50 AM
@paul_cardinale wrote:
@mike-o-tronic wrote:
I love the radio button! But it has the limitation that it groups your buttons together on the front panel. You lose the ability to place them anywhere.
Well then try nested event structures:
I'd be scared to suggest that to just about anybody.
05-08-2020 06:57 AM
@RavensFan wrote:
@paul_cardinale wrote:
@mike-o-tronic wrote:
I love the radio button! But it has the limitation that it groups your buttons together on the front panel. You lose the ability to place them anywhere.
Well then try nested event structures:
I'd be scared to suggest that to just about anybody.
It's not hard to get this one right, and it's easy to check. If you get it wrong, it will sieze up; then just abort, fix and retry. In my opinion, this is a very good solution to this particular problem.