Thread Subject: call "callback function" again

Subject: call "callback function" again

From: ching l

Date: 24 Jul, 2008 17:26:01

Message: 1 of 3

function pushbutton9_Callback(hObject, eventdata, handles)

if handles.randValue <=5
   
;

else
    
wavplay(ssamples{handles.randValue}{:}) ;

end


Instead of "doing nothing" when the handles.randValue <=5,
how do I call the "callback function" again? I want it
persistently call the "callback function"

if handles.randValue <=5

 set(hObject, 'Callback', '');


this is what I tried, but not right...


Subject: call "callback function" again

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 24 Jul, 2008 17:38:51

Message: 2 of 3

In article <g6adv9$4do$1@fred.mathworks.com>,
ching l <chinglnc@hotmail.com> wrote:
>function pushbutton9_Callback(hObject, eventdata, handles)

>if handles.randValue <=5
>;
>else
>wavplay(ssamples{handles.randValue}{:}) ;
>end

>Instead of "doing nothing" when the handles.randValue <=5,
>how do I call the "callback function" again? I want it
>persistently call the "callback function"

>if handles.randValue <=5
> set(hObject, 'Callback', '');
>this is what I tried, but not right...

function pushbutton9_Callback(hObject, eventdata, handles)
  if handles.randValue <= 5
    cb = get(hObject, 'Callback');
    cb{1}(hObject, eventdata, handles);
  else
    wavplay(ssamples{handles.randValue}{:});
  end


This code does what you asked; unfortunately what you asked for
is highly unlikely to be useful for anything other than crashing
your program with a complaint about the recursion limit being
exceeded.

Wouldn't it be wiser to at least change the value of handles.randValue
before calling the same routine again?

--
  "Is there any thing whereof it may be said, See, this is new? It hath
  been already of old time, which was before us." -- Ecclesiastes

Subject: call

From: ching l

Date: 24 Jul, 2008 18:09:01

Message: 3 of 3

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <g6aenb$ki4$1@canopus.cc.umanitoba.ca>...
> In article <g6adv9$4do$1@fred.mathworks.com>,
> ching l <chinglnc@hotmail.com> wrote:
> >function pushbutton9_Callback(hObject, eventdata, handles)
>
> >if handles.randValue <=5
> >;
> >else
> >wavplay(ssamples{handles.randValue}{:}) ;
> >end
>
> >Instead of "doing nothing" when the handles.randValue <=5,
> >how do I call the "callback function" again? I want it
> >persistently call the "callback function"
>
> >if handles.randValue <=5
> > set(hObject, 'Callback', '');
> >this is what I tried, but not right...
>
> function pushbutton9_Callback(hObject, eventdata, handles)
> if handles.randValue <= 5
> cb = get(hObject, 'Callback');
> cb{1}(hObject, eventdata, handles);
> else
> wavplay(ssamples{handles.randValue}{:});
> end
>
>
> This code does what you asked; unfortunately what you
asked for
> is highly unlikely to be useful for anything other than
crashing
> your program with a complaint about the recursion limit being
> exceeded.
>
> Wouldn't it be wiser to at least change the value of
handles.randValue
> before calling the same routine again?
>
> --
> "Is there any thing whereof it may be said, See, this is
new? It hath
> been already of old time, which was before us." --
Ecclesiastes


Sorry if the question is confusing,

I have two group of similar callback function:

function group1_CreateFcn(hObject, eventdata, handles)

[audio, fs] = wavread('F:\matlab_gui\speech');
ssamples{1} = {audio, fs};
[audio, fs] = wavread('F:\matlab_gui\gtr');
ssamples{2} = {audio, fs};

%all the way up to {99}
%*******

function group2_CreateFcn(hObject, eventdata, handles)

[audio, fs] = wavread('F:\matlab_gui\speech');
ssamples{100} = {audio, fs};
[audio, fs] = wavread('F:\matlab_gui\gtr');
ssamples{101} = {audio, fs};

%*******


so when I do this for both;

handles.randValue = ceil(length(ssamples)*rand);

the Group 2 essentially generate the rand value for Group 1
also, which is something that I don't want.

So, I want to limit group 2 so that the handles.value only
start from {100} onwards.

The only way that I can thought of is to call the
CallFunction of Group 2 when handles.value is larger than {99}.

Or is there any better way to do it? The reason that I break
into two groups is that the push button has great latency
for Group 1 (which was originally more than 150 files).

please advice.
  



Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com