uiresume to allow code to run with dialog box still open?

9 views (last 30 days)
Hi All,
here's what I would like to do: I would like to open up a questdlg() that would allow the user to stop the script (something like a switch statement to quit), but I would like the script to continue running if the user does nothing.
The reason is that I am controlling some equipment with a matlab script, and sometimes things don't go as planned. When they don't go as planned however, I currently have to ctrl+C out, but then scramble to run another code I have that zeros out and shuts off the equipment (which when I ctrl+C out of the script is unaffected). So what I'm trying to introduce is a way to exit the script in a controlled way - appropriately shutting down the equipment.
Thanks for any advice.

Answers (2)

Daniel Shub
Daniel Shub on 22 Apr 2012
This is the basics of a gui. There are lots of demos and documentation of how to make a gui. Basically you want a one button gui with the callback of the button being your shutdown function.

Walter Roberson
Walter Roberson on 22 Apr 2012
You have two different requests: to do something if a user does nothing, and to have a way to gracefully exit the script.
To gracefully exit the script, see this part of the questdlg() documentation:
The dialog has three default buttons, Yes, No, and Cancel. If the user presses one of these three buttons, button is set to the name of the button pressed. If the user presses the close button on the dialog without making a choice, button is set to the empty string.
So your code should detect Cancel or close of the dialog and do a graceful shutdown.
The timeout... tricky unless you hack the questdlg() code. You would need to set a timer, but before you start the questdlg() code, you do not know the number of the figure generated by questdlg() so you would not know what to uiresume, not unless you can findobj() it after the timer expires.

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!