12-17-2009 10:18 AM
Solved! Go to Solution.
12-17-2009 10:26 AM
Your description is not clear. Can you show us some code, or at least a picture of it.
Why would a button state prevent exiting the program? Makes no sense! 😮
12-17-2009 10:28 AM
Set the button to the desired state (T/F). On the front panel, right click on the button. Select Data Operations/Make Current Value Default.
Otherwise you can use a sequence structure to set the value with a local variable in the 0th frame and run your loops in the 1st frame.
12-17-2009 10:30 AM
12-17-2009 10:32 AM - edited 12-17-2009 10:33 AM
12-17-2009 10:36 AM
12-17-2009 11:16 AM
I have tried several of the suggestions but I cannot get it to work. I have attached the while loop and event structure used to exit the VI. The constant F and two local variables to the right are the variables that I need set to false when the program closes. Any ideas?
12-17-2009 11:20 AM - edited 12-17-2009 11:22 AM
You should include the "write to local variables" on the right inside flat sequence, and wire the loop stop boolean to the structure (by doing so, you force the execution of the flat sequence AFTER you exit the loop).
Anyway, I'm missing something: according to the picture you've posted, your controls should be initialized to false as you launch the program...
12-17-2009 11:51 AM
You have a classic race condition. Since there is no data dependency, writing to the locals occurs in parallel with the execution of the while loop. LabVIEW does NOT execute left-to-right. Execution order is entirely dictated by dataflow.
There is no need for sequence frames and such. Simply place the FALSE diagram constant inside the loop and wire to the two locals outside the loop. This data dependency ensures that the locals cannot be written until the while loop has completed.
Think dataflow! 🙂
Othere things make little sense: for example why do you need to unbundle the status with every iteration of the loop? That operation belongs before the loop, in fact you should bypass the loop if the status is true.