Losing track of time

Scott Rossi scott at tactilemedia.com
Sat Aug 9 20:16:41 EDT 2003


On 8/8/03 10:30 AM, "Howard Bornstein" <bornstein at designeq.com> wrote:

> I've got a simple reminder program that takes a number (representing
> minutes) and plays a chime when that many minutes is up.
> 
> The reminder script is:
> 
> on reminder
> global SendID
> 
> put fld "TheTime" into timer
> send reminder to me in timer*60 seconds
> put the result into sendID
> play "chime2.wav"
> 
> end reminder
> 
> 
> The problem is that, for example, if I set the timer to chime every hour,
> I am losing about 5 seconds each time I cycle through. Originally, this
> was because I had the play "chime2.wav" command before the send reminder
> command. So it would play the chime, which takes several seconds, before
> resetting the time.
> 
> But now I've switched the order to the above handler and I'm *still*
> getting this lost time per cycle.
> 
> Is it possible that the play command somehow stops the internal timer of
> the send command? This seems highly unlikely but I can't think what else
> would be causing this delay, which pushes me further past the hour as the
> cycles continue.
> 
> Any ideas?

Possibly.  Running your own timer might eventually get "out of sync" due to
delays caused by mouse events in the stack, low level events that are
processed by Rev, the system, etc.

You might consider forgoing your custom timer and instead poll the current
time infrequently.  For example:

on reminder
 
 # GCHIMETIME IS THE NEXT DESIGNATED CHIME HOUR (ie 11:00)
 global gChimeTime
 if word 1 of the time = gChimeTime then
   play "chime2.wav"
   convert gChimeTime to seconds
   add (60*60) to gChimeTime
   convert gChimeTime to time
   send "reminder" to me in 60 seconds #ALLOW TIME TO ADVANCE PAST THE HOUR
 else send "reminder" to me in 5 seconds
 
end reminder

Alternatively, you could send the time poll event repeatedly *around* the
designated hour (say 30 seconds before to allow for delays, slowdowns, etc),
and then send the next time poll event only when the current time is equal
to the designated chime time.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com




More information about the use-livecode mailing list