08-29-2012 09:19 AM - edited 08-29-2012 09:27 AM
Hi,
I would like to get some advice on how to create a stop warning when I stop my program. I tried some ways but I am unable to reset my Stop button to false when I click No.
Thanks!!!
08-29-2012 09:34 AM - edited 08-29-2012 09:34 AM
Use an Event Structure for your GUI. In the stop value change event, put your warning dialog. If accepted, set a global variable. If reject, do not set it. Given what you have shown, I would use a global variable for the stop condition. Your second loop can just poll the stop global variable instead of getting the value through a property node.
08-29-2012 10:05 AM
@crossrulz wrote:
Use an Event Structure for your GUI. In the stop value change event, put your warning dialog. If accepted, set a global variable. If reject, do not set it. Given what you have shown, I would use a global variable for the stop condition. Your second loop can just poll the stop global variable instead of getting the value through a property node.
I agree with the answer provided but would recommend propigating your stop condition through some other means than a global variable. I would use a notifier or user event instead. While global/local variables can be used safely they can be quite problematic if they are not used carefully.
08-29-2012 10:08 AM
Hi Crossrulz,
The code with property node is my subvi. I am trying to stop it from my main program. In my subvi there is some process when I stop the program, I used the reference to stop the subvi too. I want to make the subvi process "pause", so I am actually thinking if I should put the warning dialog in my subvi?
08-29-2012 10:15 AM
I like to keep all of the user interaction in 1 section of code. So I would keep it in the event structure. What you can do, though, is have a messaging system of some sort (Notifier would probably be best). The messenger should have at least 3 messages (Run, Pause, Stop). When the stop button is pressed, send the Pause. If the user cancels, send the Run. If the user accepts, send Stop. Have your subVI respond accordingly.