06-14-2013 05:43 PM - edited 06-14-2013 05:45 PM
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!
06-14-2013 06:02 PM
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.
06-19-2013 01:02 AM
Thanks Mark, but sorry I still can not quite follow you, an example is more appreciated, is this what you mean? Thanks agian.
@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.
06-19-2013 02:57 AM - edited 06-19-2013 02:58 AM
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.
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. 😄
06-19-2013 03:39 AM
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.
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. 😄