LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Odd behavior in case structure

I'm having a little issue with an event structure, and I think it may just be a problem with me not fully understanding how event structures work.  I made a little VI to demonstrate my problem.  I have a radio button selector.  One of the cases in my event structure is a value change for the radio buttons.  I would like to enable or disable a string control based on the radio button selection.  I am doing this via property nodes.  I have a case structure inside the value change case, and the selector for the case structure is the radio button control.  What's happening is that when I choose to disable the string control, it enables it.  When I choose to enable it, it disables it.  I know that I can fix this by swapping the cases, but it just doesn't make sense to me.  Can someone please explain why it's doing that?  Thanks!

Oh yeah, using LV 8.2.1.
0 Kudos
Message 1 of 5
(2,537 Views)
With the control outside of the event structure, you're getting old data. Put the control inside the event or wire up the NewVal element to the case structure.
Message 2 of 5
(2,527 Views)

So the problem you are seeing is a data flow issue and not really an event structure issue.  Turn on highlight execution and watch how the code runs.

Basically the Radio button is read at the begining of the loop.  Then the event structure is hit.  So if the control is at enable LV "reads" that value and sends it down the wire then waits at the event strucure.  Now you change the value and the event executes, however the value on the wire is the old value.

So to fix this all you need to do is move the radio button terminal inside the event strucutre, so that LabVIEW will "read" the value once the event has fired not before.

Message 3 of 5
(2,523 Views)
You need to place the terminal of the radio button INSIDE the event case.
 
What happens at the moment is that the radio button control gets read at leasure and its value travels to the input tunnel to the event structure. When the event fires, it will NOT go back and read the control again, but use the value from the tunnel.
 
Two solutions:
  • Use the "new value" event terminal to decide on the case.
  • place the radio button terminal inside the event case (now it won't get read until the event fires).

All clear? 🙂

(Sometimes operating the VI with execution highlighting will easily tell you what's going on. Try it!)

Message 4 of 5
(2,519 Views)
Ok, I see.  For some reason, I thought the radio buttons needed to be outside the case structure in order to use the value change event for that.  Thanks guys!
0 Kudos
Message 5 of 5
(2,515 Views)