LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
SectorEffector

Wiring a control reference to a case structure

Status: Declined

Any idea that has received less than 5 kudos within 5 years after posting will be automatically declined.

Suggestion

 

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 mostly 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!

 

--------------------------------
The Enrichment Center is required to remind you that you will be baked, and then there will be cake.

6 Comments
crelf
Trusted Enthusiast
I usually wire the contol reference into a "name" property node, and then wire the output of that into the selector of the case structure.




Copyright © 2004-2023 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
Knight of NI
That's what I've done as well (with the possible option of making the case structure matching case-insensitive). Simple, effective, and no need to make such a fundamental change to LabVIEW whose benefits are questionable.
AristosQueue (NI)
NI Employee (retired)

If you've already got "the rest of the code" packaged as a subVI, then I suggest you have a different frame of your Event Structure for each of those buttons, do the thing specific to each button in that frame and then call the subVI -- it eliminates the case structure entirely. Faster to code and faster to execute.

 

If you don't have "the rest of the code" packaged as a subVI, you either a) should make it a subVI or b) have a good reason why the replicated code might not be the same in the future, in which case having copies of it in different frames of the event structure is desirable.

altenbach
Knight of NI

Of course I agree there are quite a few ways around it, but the general idea per se is not bad and gives simple and self-documenting code.

 

Alternatively, we could have an event terminal that provides an enum with all handled control names of that event structure (or "-none-" for other events), which then could be fed to the case selector.

 

Message Edited by altenbach on 08-31-2009 03:46 PM
Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 5 kudos within 5 years after posting will be automatically declined.

M.Dahmani
Member

Hey,

 May be that can Help you ..2020-06-25 08_50_50-Window.png