Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!newsfeed.stanford.edu!newsfeed.news.ucla.edu!nrc-news.nrc.ca!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Send an interrupt from a GUI
Date: Fri, 11 Jul 2008 19:29:14 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 40
Message-ID: <g58caa$cja$1@canopus.cc.umanitoba.ca>
References: <g581oe$ic8$1@fred.mathworks.com> <g58auq$sfr$1@fred.mathworks.com> <g58bum$9d5$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1215804554 12906 192.70.172.160 (11 Jul 2008 19:29:14 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Fri, 11 Jul 2008 19:29:14 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:478918



In article <g58bum$9d5$1@fred.mathworks.com>,
David Doria <daviddoria@gmail.com> top-posted:

Please do not post your reply above what you are commenting on,
as it makes it difficult to hold a conversation.

>> function testAbort

>> figh = figure;
>> btn = uicontrol('style', 'pushb', 'string', 'Abort', ...
>>                 'callback', @doAbort);
>> isAborted = false;

>> % simulate a long-running computation with PAUSE
>****
>longFunction(); %unable to check button status from inside
>this function!
>***

>> %% =====
>>     function doAbort(h,e)
>>         isAborted = true;
>>     end
>> 
>>     function checkForAbort()
>>         if isAborted, 
>>             error('Aborted');
>>         end
>>     end
>> end

>Well the problem is more that the loop that you call
>"checkForAbort" from is in a separate m file and therefore
>wouldn't have access to the button control.  Do you see the
>difference?

Count the 'end' statements, Dave. Gautam used a nested function.
-- 
  "I will not approve any plan which is based on the old principle
  of build now and repair later."                   -- Walter Hickle