LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how get cluster element value change event


@GokulGKM wrote:

You can easily create a seperate event for each cluster element.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

i know this way. why i asking this mean i have lot of even structure so need to reduce the number of event structure in my program.


Event Structures or Event Cases?  A single Event Structure can have many Event Cases and you can have event cases handle multiple events.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 11 of 32
(3,224 Views)

"Divide and conquer"

 

... can be used if you create sub-VI for the various modes of operation. Put the config actions in a config VI that is passed control refs and dynamically registers event against the controls that are config related. All of the sub-VIs that run like that can all register their own events against a common stop button. I have delivered applications that use bunch of event structures but none of them in the main VI that houses the controls and indicators. My "LabVIEW Basics I and II" customers have been able to support the code with little help from me using this approach.

 

 

Just offering another way to reduce the number of envet structures in a VI.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 12 of 32
(3,207 Views)

As I said, this would only be for an app that has a lot of controls; and therefore needs to capture a lot of value change events.

Instead of having one event structure with a very long list of cases, they are nested.  The outer event structure capturing Value Change events for various clusters, and inner event structures to handle the value changes for individual cluster elements.  This makes it easier to navigate the code.

 

While you can create problems by nesting event structures, it is possible to do it correctly.

 

Rules such as "Always do X" and "Never do Y" should really be "It's usually best to do X", and "Beware of doing Y".

 

"If you weren't supposed to push it, it wouldn't be a button."
Message 13 of 32
(3,201 Views)

I really like this idea of nesting event structures. Even if it is not recommended. But it makes the event structure code much more readable.

0 Kudos
Message 14 of 32
(3,054 Views)
No, it does not!
0 Kudos
Message 15 of 32
(3,030 Views)

That's your opinion.  Mine is different.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 16 of 32
(3,021 Views)

Nesting event structures is a very bad idea.  In theory you can do it and it could work, but it is just a small programming error away from having an ugly mess of code that will lock up tight when you execute something.

 

I would strongly discourage anyone from ever doing it.

 

Spoiler
Just because someone says something is their opinion doesn't make it a good idea or even a correct statement.
Message 17 of 32
(3,008 Views)

Just because it's easy to mess up something doesn't mean it should never be done.  And it isn't that hard to properly nest event structures; it only requires a little dilligance.

You said "In theory you can do it and it could work"; I do it, and in practice, it works fine.

As for programming errors that cause lockups, I don't find those so hard to debug.

In general, I don't believe in adhering to programming practices that are designed for the specific purpose of hamstringing inept programmers in a vain effort to get decent code out of them.

 

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 18 of 32
(2,996 Views)

Just because you can do something and it can work, doesn't mean you should do that.

 

And you certainly shouldn't suggest something that can easily be messed up to someone who doesn't even know the basics of how to use an event structure yet.  That is a complete disservice to them, anyone who has to use their code, and anyone who has to clean up their code after them once it breaks.

0 Kudos
Message 19 of 32
(2,981 Views)

You wrote "Just because you can do something and it can work, doesn't mean you should do that.".  I agree with that, and never implied to the contrary.

However I disagree about your admonition to never offer challenging approaches to beginners (especially in this case where it's not particularly challenging).

 

I find your assertion of absolutes somewhat entertaining.  Things like "you certainly shouldn't suggest", and "That is a complete disservice".

Thank you for your advice; but I'll ignore it.

 

Hamstrings will never protect us from bad programmers.

 

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 20 of 32
(2,960 Views)