LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Register Event from a control within an array

Solved!
Go to solution

I am attempting to register the "Remove" button for each active array element. I'm well versed in the Register Dynamic Event nodes but am struggling to access the reference for an individual control within the array.

 

Is this possible?

 

Thanks,

Craig

0 Kudos
Message 1 of 8
(3,640 Views)
Solution
Accepted by topic author craige

Do a plain "value changed" on the entire array, on the event data node, compare old and new (you'll get an array of clusters with all booleans, and find the one that has changed (i.e. is TRUE).

0 Kudos
Message 2 of 8
(3,628 Views)

yea, that's what I ended up doing. Thanks for the suggestion. I guess this means there's no way to access the individual control references even though they must exist in memory somewhere inside VI Server.

0 Kudos
Message 3 of 8
(3,620 Views)

Not sure why you have the "NOT" in there. Shouldn't the loop stop if a TRUE is found?

 

Here's similar code from one of my old programs:

 

(Some elements are numeric and some boolean, etc. Depending on what changed, some other cluster elements of that array element will be updated. Some cluster elements act as controls and some as indicators (disabled).

 

 

0 Kudos
Message 4 of 8
(3,603 Views)

Arrays of a control are really just arrays of values. There is one control reference for the array's element type. The only thing that can differ for each array element is the value of the control (be it a boolean or a cluster etc). So all you can do is get the index of the array that has changed using the code shown above and operate on the Array values (replace/insert/delete).

0 Kudos
Message 5 of 8
(3,573 Views)

The 'not' is necessary because I'm not looking for when Remove is "TRUE" but rather when the previous value and the new value are not equal (meaning I've selected True). Yes, it's confusing which is why it would have been nice to simply register an event callback.

0 Kudos
Message 6 of 8
(3,538 Views)

Ah, yes. You are doing an "equal" comparison, while I always do a "not equal", so I don't need the NOT, but you do.

 

Of course you could probably still get rid of it by changing the termination condition to "continue if true" and swap the select node inputs. 😄 

0 Kudos
Message 7 of 8
(3,535 Views)

@craige wrote:

I guess this means there's no way to access the individual control references.


There actually is, but you don't want to use them for what you are trying to do.  There are properties to get a reference to the control inside the array, but if you do something like get the value of that reference, it will change based on what index the user last interacted with.  

 

This is an undocumented behavior and NI recommends against trying to get the value of a element of an array, using its reference.  In an array every element varies only by value, so the control reference can be used for things like reading and writing properties of the control, which are always shared among all elements of the array.  To get the reference to a control in an array, use the Array Element >> Reference property node on the array.

0 Kudos
Message 8 of 8
(3,493 Views)