Re: how to make things happen at specific times

2009-04-08 Thread Sarah Reichelt
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
end scheduleMessage


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 .
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.

HTH,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: how to make things happen at specific times

2009-04-08 Thread J. Landman Gay

Sarah Reichelt wrote:

function getNextDueTime
 get the date && "4:00 PM"
 convert it to dateitems
 add 1 to item 3 of it
 convert it to seconds
 return it - the seconds
end getNextDueTime


Don't forget to allow for times between 4 pm and midnight.
Using this script would queue a message in a negative number of
seconds which would either never happen, or happen as soon as possible
and keep happening.
I have some heavily tested scripts for this which I can post later if
people are interested.


I guess you'd better...obviously I didn't think of it. ;)

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: how to make things happen at specific times

2009-04-08 Thread Sarah Reichelt
> function getNextDueTime
>  get the date && "4:00 PM"
>  convert it to dateitems
>  add 1 to item 3 of it
>  convert it to seconds
>  return it - the seconds
> end getNextDueTime

Don't forget to allow for times between 4 pm and midnight.
Using this script would queue a message in a negative number of
seconds which would either never happen, or happen as soon as possible
and keep happening.
I have some heavily tested scripts for this which I can post later if
people are interested.

One caveat about pending messages Craig: they are not guaranteed to
happen exactly when scheduled. They will happen as soon as Rev is not
busy doing something else. In normal use, this is good enough, but it
means that you cannot rely on them for exact timings.

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: how to make things happen at specific times

2009-04-08 Thread DunbarX
Queued messages. They thought of everything.

Craig


In a message dated 4/8/09 4:45:43 PM, jac...@hyperactivesw.com writes:


> 
>   -- do alarm stuff, then retrigger next event:
>    send "myAlarm" to me in getNextDueTime() seconds
> 
> When the alarm goes off, your handler calculates the next due time and
> inserts the new message into the pending event queue.
> 
> Pending messages are not saved between sessions, so you'll have to
> reload any permanent alarms on each launch.
> 




**
New Deals on Dell Netbooks – Now starting at $299 (A 
HREF=http://pr.atwola.com/promoclk/100126575x1219939010x1201342897/aol?redir=http:%2F%2Fa
d.doubleclick.net%2Fclk%3B213771626%3B35379597%3Bw)
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Re: how to make things happen at specific times

2009-04-08 Thread J. Landman Gay

dunb...@aol.com wrote:

I need to understand how pending messages are stored.

But going back to the stone age, I have several "alarms" running at all, 
er, times, and I have always used an "idle" handler to invoke them:


on idle
   if the long time = "4:00:00 pm" then
   wait 100 -- as Sarah says, make sure this only happens once
   send yourMessage to whereEver
end idle

You could embellish this endlessly; case structures come to mind. I have 
several library stacks always running with such handlers in them, so it 
doesn't matter what working stacks might be open; the message is sent.


In general, idle handlers should be avoided. They take up lots of engine 
time, and usually 99% of the time they execute, nothing happens.


Instead, Rev offers the "send  in " command that lets 
you place messages in a queue, where they will execute at the time you 
indicate. You can check this queue by looking at the pendingMessages 
property, which is also available in its respective message box pane. By 
placing an event in the queue, the engine isn't tied up needlessly by 
constantly checking for something that usually doesn't have to happen.


In the example above, you could schedule a single event to take place 
every day at 4 PM. Basically you'd calculate the number of seconds until 
the next alarm time, and then queue the message to trigger at that time:


function getNextDueTime
  get the date && "4:00 PM"
  convert it to dateitems
  add 1 to item 3 of it
  convert it to seconds
  return it - the seconds
end getNextDueTime

and in an alarm handler:

  -- do alarm stuff, then retrigger next event:
  send "myAlarm" to me in getNextDueTime() seconds

When the alarm goes off, your handler calculates the next due time and 
inserts the new message into the pending event queue.


Pending messages are not saved between sessions, so you'll have to 
reload any permanent alarms on each launch.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: how to make things happen at specific times

2009-04-08 Thread DunbarX
I need to understand how pending messages are stored.

But going back to the stone age, I have several "alarms" running at all,
er, times, and I have always used an "idle" handler to invoke them:

on idle
   if the long time = "4:00:00 pm" then
   wait 100 -- as Sarah says, make sure this only happens once
   send yourMessage to whereEver
end idle

You could embellish this endlessly; case structures come to mind. I have
several library stacks always running with such handlers in them, so it
doesn't matter what working stacks might be open; the message is sent.

Craig Newman


**
New Deals on Dell Netbooks – Now starting at $299
(A
HREF=http://pr.atwola.com/promoclk/100126575x1219939010x1201342897/aol?redir=http:%2F%2Fad.doubleclick.net%2Fclk%3B213771626%3B35379597%3Bw)
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: how to make things happen at specific times

2009-04-08 Thread Sarah Reichelt
On Wed, Apr 8, 2009 at 6:00 PM, Peter Alcibiades
 wrote:
>
> Sarah, thanks!  The thing that still puzzles me is this.  They come in and
> start up the stack.  They may do this every day, or they may leave it
> running for a few days.  Every day at 4pm it should send an email.
>
> So yes, you could check the time when the stack is started, subtract the
> time from 4pm, and then wait that number of seconds.  But what happens the
> next day at 4pm?
>
> AHA,HE SEES IT!
>
> You need a loop.  First on startup find the time to 4pm.  Then what happens
> at 4pm is to send the email, wait a couple of hours, and invoke the 4pm
> script again  Yes, it should do it.  Thanks.
>

That's it :-)

For apps where I have a lot of these messages in the pendingMessages
queue, I make a checkMessages handler that gets called more
frequently. It checks all the required pending messages and if one is
missing from the list, it sets it up again at the appropriate time.

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: how to make things happen at specific times

2009-04-08 Thread Peter Alcibiades

Sarah, thanks!  The thing that still puzzles me is this.  They come in and
start up the stack.  They may do this every day, or they may leave it
running for a few days.  Every day at 4pm it should send an email.

So yes, you could check the time when the stack is started, subtract the
time from 4pm, and then wait that number of seconds.  But what happens the
next day at 4pm?

AHA,HE SEES IT!  

You need a loop.  First on startup find the time to 4pm.  Then what happens
at 4pm is to send the email, wait a couple of hours, and invoke the 4pm
script again  Yes, it should do it.  Thanks.

-- 
View this message in context: 
http://www.nabble.com/how-to-make-things-happen-at-specific-times-tp22942579p22945285.html
Sent from the Revolution - User mailing list archive at Nabble.com.

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: how to make things happen at specific times

2009-04-07 Thread Sarah Reichelt
On Wed, Apr 8, 2009 at 1:57 PM, Peter Alcibiades
 wrote:
> What;s the approved method of doing something at a particular time?  Like,
> it would be nice to be able to send a daily email at for instance 4pm?  Is
> it necessary to check the time every so often and see what time it is,
> with a frequency proportional to the desired precision?

Calculate the number of seconds until your required time, then use
"send in time" to have your handler called at that time.
Just make sure that you don't re-schedule the next day's event until
at least 1 second has passed, or it might do it again immediately.

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution