How to terminate a script using a pushbutton i GUI?

4 visualizaciones (últimos 30 días)
JoE
JoE el 28 de Abr. de 2014
Comentada: JoE el 30 de Abr. de 2014
Hi all,
I have a GUI with a few buttons that makes some analysis for me. The duration of this analysis can be in range of few seconds to few minutes.
How can I terminate this analysis (manually finish the script behind this analysis) using one of those buttons (e.g. with the caption 'STOP')?
Is there a way how to do this in GUI (command, keyword or anything else)?
Thank you very much for your response.
JoE

Respuestas (1)

Kyle C
Kyle C el 28 de Abr. de 2014
I'm guessing that if the scripts are taking that long you have some loops in there. One way to stop the scripts is to have the stop button set appdata that signals to the scripts that they should stop running. The loops in the scripts should check to see if this signal is telling it to stop or not before each iteration.
sample:
stopbutton callback
setappdata(0,'stopreq',1)
end
functiontostop callback
if ~getappdata(0,'stopreq')
code here
else
setappdata(0,'stopreq',0)
break
end
for this to work the functiontostop must be interruptable.
  1 comentario
JoE
JoE el 30 de Abr. de 2014
Thanks for the response. I tried this but it did not work. What did you mean the function "functiontostop" must be interruptable?

Iniciar sesión para comentar.

Categorías

Más información sobre App Building en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by