octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #32316] Feature request: timer object function


From: anonymous
Subject: [Octave-bug-tracker] [bug #32316] Feature request: timer object functions
Date: Tue, 29 Dec 2015 22:55:09 +0000
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36 OPR/34.0.2036.25

Follow-up Comment #3, bug #32316 (project octave):


Depending on what you want you may get the required functionality by input
event hooks and some not so elegant work-arounds. 
For example, I wanted to update a figure plot data periodically while
releasing the prompt/terminal for user interaction (i.e. a while and usleep
would not do). 
Here is what I did:


% testimer.m:
1;

function timer_Callback() 
        persistent lastupdate = 0;
        newtime = time();
        if(newtime > lastupdate)
                disp('update');         
                fflush(stdout);
                lastupdate = newtime;
        end
end

function closefcn(src,evnt)
        global f;
        global timer_id;
        remove_input_event_hook(timer_id);      
        disp('Closing figure... Bye!');
        fflush(stdout);
        delete(f);
end

global f;
f = figure;

global timer_id;
timer_id = add_input_event_hook(@timer_Callback); 
set(f,'CloseRequestFcn',@closefcn)
 

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?32316>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]