Continue code with questionbox open

1 view (last 30 days)
Hi,
For a project I need a simple concept: While a questionbox is open, I need to continue running the code.
The basic idea is this:
y=questbox('Do you want to quit the while loop?')
while y~=('Yes')
disp('Useful code here')
end
But, ofcourse, this code will pause when the questionbox is called. Is there a way this doesn't happen but that the question could still affect the rest of the code?
Thanks in advance
  2 Comments
Sean de Wolski
Sean de Wolski on 18 Apr 2013
But how could this work? What is the point of the question box since you would either have to predefine y, and this is the y that will be used or it will error for no variable y.
What are you trying to do?
Fontys
Fontys on 18 Apr 2013
The end result must be that as long as there is no answer given, the while loop keeps looping.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 18 Apr 2013
No, you cannot do this with questbox()
  2 Comments
Fontys
Fontys on 18 Apr 2013
Is there a way I can do this in another setting? With a dialog box or something?
Walter Roberson
Walter Roberson on 18 Apr 2013
Create a pushbutton, say handles.stopbutton . Then at the place you have the questbox and "while" in your code, change it to
set(handles.stopbutton, 'Enable', 'on')
while true
drawnow();
if get(handles.stopbutton, 'Value') > 0; break; end
disp('USeful code here');
end
set(handles.stopbutton, 'Value', 0, 'Enable', 'off');

Sign in to comment.

More Answers (0)

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!