LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Button help please

Solved!
Go to solution
Thank You I can work with this.Smiley Happy
0 Kudos
Message 21 of 22
(1,163 Views)

chilly charly wrote:

Since you placed the Buttons control inside the event structure, do you think a possibility of race condition still exists (except if the "lock FP until the event complete" default behavior of the event frame was changed) ?


The old code had two possible flaws. I don't think it has anything to do with "lock FP". I am pretty sure that once the event executes, LabVIEW will read from the terminal before the local variable gets written, but why take the chance to rely on undocumented priorities? There is not data dependency!

 

The more serious flaw was the fact that I write the old value back to it instead of an array of all FALSE. Again, in normal operation, there will be no problem, but imagine if some other parts of the code woud write several TRUEs to the array via a local variable and then some other TRUEs via a value(sgnl) property. Now the "oldval" will NOT be all FALSEs and things will get out of sync.

 

In the most simple case, we always have exactly one TRUE in the newval and we don't need the comparison and can simply use the "newval" or terminal. The comparison protects agains the case where again the array changes in some way via a local variable. It will detect the clicked button no matter how the old values are and then cleanup the array.

 

The comparison is useful in many other cases, e.g. in an array of numerics where we want to know which element got changed. It's part of my universal coding habits. 🙂

 

So, if the rest of the code is sane (and it probably is!), we can do the following even simpler code. (Again, I delay the local write via a data dependency, just out of possibly misguided paranoia. :D)

 

Message Edited by altenbach on 01-04-2009 10:55 AM
Download All
Message 22 of 22
(1,159 Views)