cancelar
Mostrando resultados para 
Pesquisar então 
Você quer dizer: 

Register Event from a control within an array

Resolvido!
Ir para a solução

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
Mensagem 1 de 8
4.971Exibições
Solução
Aceita pelo autor do tópico 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
Mensagem 2 de 8
4.959Exibições

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
Mensagem 3 de 8
4.951Exibições

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
Mensagem 4 de 8
4.934Exibições

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
Mensagem 5 de 8
4.904Exibições

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
Mensagem 6 de 8
4.869Exibições

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
Mensagem 7 de 8
4.866Exibições

@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
Mensagem 8 de 8
4.824Exibições