Continue code with questionbox open

2 次查看(过去 30 天)
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 个评论
Sean de Wolski
Sean de Wolski 2013-4-18
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 2013-4-18
The end result must be that as long as there is no answer given, the while loop keeps looping.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2013-4-18
No, you cannot do this with questbox()
  2 个评论
Fontys
Fontys 2013-4-18
Is there a way I can do this in another setting? With a dialog box or something?
Walter Roberson
Walter Roberson 2013-4-18
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');

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by