Timer Application

Devin Asay devin_asay at byu.edu
Wed May 28 12:54:34 EDT 2008


On May 28, 2008, at 12:32 AM, RevList wrote:

> Does anyone have a sample timer application where you can pick a  
> start and
> end time and have some function or subroutine called if it is between
> those times?

Stewart,

I reread your message and realized I misinterpreted it the first  
time. If I understand correctly, you want something to happen only  
during a specific time window. Here is one possible approach (not  
tested).

Let's say you want the handler to be triggered during some five  
minute window starting at a time you specify in field "openWindow".  
So this field may have, say, "11:30 AM" in it. So in your card script  
you might have:

local tStart, tEnd

on loadEventTrigger
   put fld "openWindow" into tStart
   convert tStart to seconds
   put tStart + (5 * 60) into tEnd
   checkWindowOpen
end loadEventTrigger

on checkWindowOpen
   get the seconds
   if it > tStart and it < tEnd then
     # do stuff here
   else
     # if not in the window, keep checking
     send checkWindowOpen to me in 1 second  # or whatever interval  
you want
   end if
end checkWindowOpen

Don't forget a way to cancel the pending message in case you leave  
the card. See the cancel command in the Dictionary.

HTRH,

Devin



Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list