Best way to repeat on a timer?

Sarah sarahr at genesearch.com.au
Sun Aug 10 22:10:00 EDT 2003


I would say that your messages are multiplying until there are dozens 
of them all firing off shell commands. In your checkStatus handler, 
before you send the next message, cancel and pending ones, with a 
script like this:

   put the pendingMessages into tMess
   repeat for each line p in tMess
     if item 3 of p contains "checkStatus" then cancel item 1 of p
   end repeat

This will cancel any checkStatus messages that are found and leave you 
with a clean slate for the next round.

Cheers,
Sarah

On Saturday, August 9, 2003, at 12:08  am, RGould8 at aol.com wrote:

> I've got an app that needs to poll the user's network settings every 3 
> seconds.  I'm presently doing this by calling a unix command via the 
> shell command in Revolution on Mac OS X.
>
> The problem I'm having is that, while this seems to work, it makes 
> dragging the application window very jittery when the app is running.  
> I suspect this is because I might be creating a memory-hogging timer 
> loop.  Here's what I'm doing:
>
> on opencard
>      send "checkstatus" to this stack
> end opencard
>
>
> on checkstatus
>      put shell(unixcallgoeshere) into field "status result"
>      send "checkstatus" to this stack in 3 seconds
> end checkstatus
>
>
> The unix call I'm using spits back it's result instantaneously, so 
> there shouldn't be a backlog via the unix side of things.  Is it bad 
> to have a handler call itself via a timer - - - does that create some 
> sort of "nesting" problem?
>    
>




More information about the use-livecode mailing list