LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event case abuse of local variables

Hi,

 

Just a simple question that how can I avoid the abuse of local varibles with event structure? Seems like if I need to update the indicators in the front panel within different event cases, local varibles are inevitable at all. Otherwise I have to bundle everything and pass them onto outside of the event structure and thereafter distribute to each indicator, which is more complicate. Am I missing something? Please advise, thanks!

0 Kudos
Message 1 of 5
(2,993 Views)

One method would be to use user events and trigger that to update an individual indicator. Any place that needs to update that indicator would trigger the appropriate user event with the correct data. However, when implementing a UI it is acceptable to use local variables within the event structure. You will not have race conditions since only one event can run at a time. This is one of the few places locals are ok to use. With that said, if I see that I am updating some particular value in many states I would simply put the indicator on the outside of the event structure and use a shift register and wire it through the event structure.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 5
(2,980 Views)
Thanks Mark, but sorry I still can not quite follow you, an example is more appreciated, is this what you mean? Thanks agian.
event.png

@Mark_Yedinak wrote:

One method would be to use user events and trigger that to update an individual indicator. Any place that needs to update that indicator would trigger the appropriate user event with the correct data. However, when implementing a UI it is acceptable to use local variables within the event structure. You will not have race conditions since only one event can run at a time. This is one of the few places locals are ok to use. With that said, if I see that I am updating some particular value in many states I would simply put the indicator on the outside of the event structure and use a shift register and wire it through the event structure.


 

0 Kudos
Message 3 of 5
(2,925 Views)

thitchen007 wrote:

Thanks Mark, but sorry I still can not quite follow you, an example is more appreciated, is this what you mean? Thanks agian.

event.png

 



 

At this point I would recommend to start with some tutorial and look at some examples. Think about it: What good is a shift register if you never even tap into the retained value coming out on the left side? As a rule of thumb, a shift register with the inner left side unwired has no useful functionality.

 

To get you started, here's a trivial example that uses a few seperate event cases to modify an example held in a shift register and displayed in an indicator. No local variables needed. 😄

 

Message 4 of 5
(2,911 Views)
Thanks to you the knight of NI, kudos to you two.




@altenbach wrote:

@thitchen007 wrote:

Thanks Mark, but sorry I still can not quite follow you, an example is more appreciated, is this what you mean? Thanks agian.

event.png

 



 

At this point I would recommend to start with some tutorial and look at some examples. Think about it: What good is a shift register if you never even tap into the retained value coming out on the left side? As a rule of thumb, a shift register with the inner left side unwired has no useful functionality.

 

To get you started, here's a trivial example that uses a few seperate event cases to modify an example held in a shift register and displayed in an indicator. No local variables needed. 😄

 


 

0 Kudos
Message 5 of 5
(2,896 Views)