Date: Feb 28, 2012 6:33 AM
Author: Martinez
Subject: GUI: Stop loops in another callback function

Hi

I have a GUI with some parameters and a start and cancel button. When I press the start button in the callback function of the start button, some calculations are done with loops. When I press the cancel button the calculations done in the start button callback should stop immediately. How can I solve this without using a global variable like this:

function start_callback(...)
global stop
stop=false;
N=1e6;
n=0;
while n<N && ~stop
%calculations
n=n+1;
end

function cancel_callback(...)
global stop
stop=true;

Thanks
Martinez