how to make things happen at specific times
sarah.reichelt at gmail.com
Wed Apr 8 18:08:22 CDT 2009
OK, here is a general function for scheduling an event:
command scheduleMessage pMessage, pHours, pMins
-- pHours is in 24 hour time
put the seconds into nextTime
convert nextTime to dateItems
put item 4 of nextTime into tHourNow
put item 5 of nextTime into tMinsNow
if tHourNow > pHours or (tHourNow = pHours and tMinsNow >= pMins)
then add 1 to item 3 of nextTime
put pHours into item 4 of nextTime
put pMins into item 5 of nextTime
put 0 into item 6 of nextTime
convert nextTime to seconds
send pMessage to this stack in nextTime seconds
-- Uncomment these lines for testing:
-- convert nextTime to short system date and long time
-- put pMessage & " scheduled for " & nextTime
Call it as follows:
scheduleMessage "sendEmail", 16, 0
to have it send the "sendEmail" command to your stack script at 4 pm.
On or after 4 pm, it will schedule the event for the following day.
The commented out lines at the end of the handler are useful when
testing to make sure it is all happening as expected.
For monitoring pending messages, I would like to recommend my Pending
Message Manager, available from <http://www.troz.net/Rev/plugins.php>.
Rev's Message box has a panel for this, but it shows the times in long
seconds which is unreadable, and it doesn't filter out glx messages
which is vital for any users of GLX2.
More information about the use-livecode