Fixed-time timers problem-help!
Sarah
sarahr at genesearch.com.au
Thu May 15 16:24:01 EDT 2003
Hi Bryan,
I have written some general purpose handlers for sending messages. They
make sure that the message is not sent multiple times and the
"sendMessageAt" handler allows you to specify a time rather than a
delay for the next message. They may not be exactly what you want, but
they may give you enough of a start to do your own thing. As usual with
emailed scripts, beware of wrapped lines that shouldn't be wrapped.
Cheers,
Sarah
-- send message at a specified time
-- use 24 hour time, so next available will be used
--
-- sendMessageAt "showClock", "fld ID 1026 of cd 1", "11:10"
--
on sendMessageAt handlerName, where, atTime
put the seconds into timeNow
put timeNow into eventTime
convert eventTime to dateItems
set the itemDel to ":"
put round(item 1 of atTime) into atHour
put round(item 2 of atTime) into atMin
set the itemDel to comma
if atHour > item 4 of eventTime or (atHour = item 4 of eventTime and
atMin > item 4 of eventTime) then
add 1 to item 3 of eventTime
end if
put atHour into item 4 of eventTime
put atMin into item 5 of eventTime
put 0 into item 6 of eventTime -- adjust to even minute
convert eventTime to seconds
put eventTime - timeNow into theDiff
setupNextCall handlerName, where, theDiff
end sendMessageAt
-- send a message in a specified number of seconds
-- clears any pending instances first
--
-- setupNextCall "showClock", "fld ID 1026 of cd 1", 60 - theSecs
--
on setUpNextCall handlerName, where, inSeconds
put the pendingMessages into pMess
repeat for each line p in pMess
if item 3 of p contains handlerName then cancel item 1 of p
end repeat
if there is not a where then exit setupNextCall
if inSeconds < 1 then
do "send " & quote & handlerName & quote & " to " & where & " in "
& inSeconds*1000 & " milliseconds"
else
do "send " & quote & handlerName & quote & " to " & where & " in "
& inSeconds & " seconds"
end if
end setUpNextCall
On Monday, May 12, 2003, at 09:06 am, Bryan McCormick wrote:
> Folks,
>
> This ought to be brain-dead simple, but I cannot for the life of me
> get this to work. I have a stack that needs to run itself at set times
> of the day. The intervals are large and fixed, that is there is a
> specific clock time involved, not just an interval.
>
> For example, I need the stack to be aware of the time of day when it
> opens and initialize itself. That part is easy.
>
> Then I need the stack to send out a request for data every half hour
> through a simple script which is working fine, so all we need is the
> timer. So that is on the half-hour and hour as follows:
>
> 9, 9:30,10, 10:30, ... all the way to 4PM.
>
> Now, the problem is "send" works great in cases where you need to
> "poll" on a regular basis or for event contro where you don't want to
> use idlel. However I don't need that at all. Ideally I would want to
> create 13 messages (13 half-hour intervals with set times) to start
> the script.
>
> It does not seem possible (at least the way I've done it) to "stuff"
> the time into the item of pendingmessages and let it go. In other
> words, I would ideally love to open the stack, get the time, have the
> 13 messages "popped" into the pendingmessages and off we go.
>
> So what have I missed? How embarrassed am I going to be at how simple
> this is?
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
>
>
More information about the use-livecode
mailing list