Continue code with questionbox open

2 Ansichten (letzte 30 Tage)
Fontys
Fontys am 18 Apr. 2013
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 Kommentare
Sean de Wolski
Sean de Wolski am 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 am 18 Apr. 2013
The end result must be that as long as there is no answer given, the while loop keeps looping.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Dialog Boxes finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by