Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!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: go to next function in one callback?
Date: Fri, 18 Jul 2008 21:41:16 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 36
Message-ID: <g5r2ls$4l8$1@canopus.cc.umanitoba.ca>
References: <g5n6am$78p$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1216417276 4776 192.70.172.160 (18 Jul 2008 21:41:16 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Fri, 18 Jul 2008 21:41:16 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:480389



In article <g5n6am$78p$1@fred.mathworks.com>,
ching l <chinglnc@hotmail.com> wrote:
>In Gui, how do I command the callback function to go to the
>next function?

>For example, when I first press the button, it will go to this, 

>function answer_faster_Callback(hObject, eventdata, handles)
>csvwrite('subject1.dat',[1;00;55]);

>then when I press again, it will go to this, 

>csvwrite('subject2.dat',[3;5;6]);

>Possible to do that?

Yes,

function answer_faster_Callback(hObject, eventdata, handles)
  persistent fargs
  if isempty(fargs)
    fargs.args = {{'subject1.dat',[1;00;55]}, {'subject2', [3;5;6]}, ...
                  {'subject3.dat',[17;8;21]}, {'subject4', [255;0;255]};
    fargs.count = 1;
  end

  csvwrite(fargs.args{fargs.count,1}, fargs.args{fargs.count,2});
  fargs.count = fargs.count + 1;
  if fargs.count > length(fargs.args)
     set(hObject, 'Callback', '');
  end
end
-- 
Q: Why did the chicken cross the Mobius strip?

A: There were manifold reasons.