Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!cornell!uw-beaver!rice!sun-spots-request From: bickel@nprdc.navy.mil (Steven Bickel) Newsgroups: comp.sys.sun Subject: Re: Need help with Sunview programming (Notifier doesn't) Message-ID: <1496@arctic.nprdc.arpa> Date: 1 Mar 89 12:12:23 GMT References: <961@ubu.warwick.UUCP> Sender: usenet@rice.edu Organization: Navy Personnel R&D Center, San Diego Lines: 60 Approved: Sun-Spots@rice.edu Original-Date: 17 Feb 89 19:10:15 GMT X-Sun-Spots-Digest: Volume 7, Issue 175, message 7 of 8 X-Issue-Reference: v7n149 jmb%warwick.uucp@nss.cs.ucl.ac.uk (James M Beckett) writes: >...I want to have the 'plot' button change to >a 'stop' button, which I can select to stop the fractal while it's drawing >if it doesn't look too good.... >My theory at the moment is that once a function has been called via the >notifier, other events are disabled until the function ends. True. Have the panels notify proc call notify_set_itimer_func(). Below is a routine that can act as a nice interface to notify_set_itimer_func(). notify_set_itimer_func() will have the system clock (via signal - don't use this unix function with notify_set_itimer_func()) call the designated routine and all panel buttons within your frame will still be active. These button will be capable of settings flags for stopping your routine. Also, your routine should immediately reset notify_set_itimer_func() with no function so that your function is not repeated. This type of procedure should also be used for panel buttons that destroy their own panel. ( I modified this code after extracting it from our application, it may need some slight modifications ie. for resetting the timer_func to NULL - I did not test it). /*-- v1.0 set_the_notify_itimer: Sets the systems interrupt routine (layer above unix signal() ) to call the timer node functions update function. Returns: void */ void set_the_notify_itimer(timer_func) void (*timer_func) (); { /* ----- Variables ----- */ static char *me = (char *) &me; struct itimerval timer; float update_interval = 0.005; /* minimal time between repeated calls */ /** BEGIN set_the_notify_itimer */ /** set the tim interval structure to pass to the system timer interrupt */ timer.it_interval.tv_usec = (int) (1000000 * (update_interval - (float) ((int) update_interval))); timer.it_interval.tv_sec = (int) update_interval; timer.it_interval.tv_sec = 0; timer.it_value.tv_usec = 1; timer.it_value.tv_sec = 0; /** set the system timer interrupt routine to be the routine passed in */ notify_set_itimer_func(me, timer_func, ITIMER_REAL, &timer, NULL); /** END set_the_notify_itimer */ } Steve Bickel bickel@nprdc.arpa Systems Engineering Assoc. (619) 553-9306 Naval Personel R & D Center.