LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple events handled in a case, variant type newval

Solved!
Go to solution

Hi!

I use an event case structure, and one case handles two value change events. One is a button's, the other is a cluster of controls'.

I would like to distinguish, whether the source was the button, or one of the controls in the cluster, but i get back the new-val and old-val in a variant type.

How could i get the appropriate values back?

Thanks 

0 Kudos
Message 1 of 6
(5,581 Views)
Do the button and the cluster of controls have to have the same event structure case? Is there anything preventing you from putting them in two separate cases and then having some sort of indicator in each of those cases to indicate what was pressed? I know this might make some duplicate code, but it could also solve the problem of figuring out which one was pressed.
0 Kudos
Message 2 of 6
(5,573 Views)

Actually I could duplicate it, but i'd like to avoid it, because the code is pretty big... and if there is an option to handle multiple events, then it'd be nice, to work it out that way.

The cluster contains simple boolean and numeric controls, and the event case looks like this:

 

"Cluster_of_controls", "button" :  Value Change

 

On the left side of the structure there is an EventSource input, but is only tells thet is was the application, or some external stuff, and not that wich control.

0 Kudos
Message 3 of 6
(5,569 Views)
Solution
Accepted by topic author wasz

For this, you would use the "ctlref" event terminal, not the "newval".

 

If you only have two controls, create a control reference for one and compare it with the ctlref event terminal. If they are equal, that was the control, else the other one. Place the terminal of both controls inside the event to get the values of each.

 

(If you have more than two controls, create an array of control references and use "search array" for the ctrlref output)

 

If your controls have unique names, you could also use the ctlref to get the control label, for example. 

Message 4 of 6
(5,549 Views)

You can figure out whether the cluster or boolean underwent the value change by using the "CtlRef" indicator on the left hand side of the event structure. Using a property node, wire the CtlRef (turqoise color). Then you can select to read the "Label.Text" property to find out which control had the value change in the form of a string.

 

Does this work for you?

Message 5 of 6
(5,547 Views)
The cltref solved my problem. Thank you very much!
0 Kudos
Message 6 of 6
(5,512 Views)