Sarah's scheduleMessage script.
Alex Tweedly
alex at tweedly.net
Wed Jul 21 19:26:37 EDT 2010
I think the problems is that following
> 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
>
you have nextTime as the value "the seconds" WILL have when the command
should be executed; but when you do
> send pMessage to this stack in nextTime seconds
>
you are asking to wait that many seconds.
I'd try changing it to
send pMessage to this stack in (nextTime - the seconds) seconds
and see if that does it.
-- Alex.
nextTime is the seconds
On 21/07/2010 23:33, Andrew Kluthe wrote:
> Hey there!
>
> I always forget to turn my p2p software on before I go to bed at night and I
> have oodles of *legal* downloads that I need to catch up on. So, I decided
> to try to make a simple timer that would open a program at a certain time
> and close it again at a certain time everyday.
>
> I came across Sarah Reichelt's scheduleMessage script on this list.
>
> The problem I am having is, the messages get queued but they never disappear
> from the pending messages queue and they never call the handlers I need. It
> lets me know they are scheduled at correct times and I can see the messages
> in the queue. Why aren't they executing?
>
> the handlers for open and closing the program work just fine. They just
> don't execute when they are supposed to.
>
> I have included the entire script here for testing purposes:
>
> on openUTorrent
> launch "C:/Program Files/uTorrent/uTorrent.exe"
> end openUTorrent
>
> on closeUTorrent
> set the hideConsoleWindows to true
> get shell("taskkill /IM uTorrent.exe")
> end closeUTorrent
>
> on setTimer
> scheduleMessage "openUTorrent", 17, 20
> scheduleMessage "closeUTorrent", 17, 23
> end setTimer
>
> 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
> answer pMessage& " scheduled for "& nextTime
> end scheduleMessage
>
More information about the use-livecode
mailing list