| This post has been thanked 1 times. |
|
||||
|
Re: Certain script run at a certain time
I like your method a little more actually. The only downside would be that mortscript would be loaded in memory during the Sleep() function. I don't know how well it would fare against system freezes or reboots, or maybe even conflicts from other scripts.
For what it's worth, you can use that method in conjunction with Unix time. Something like: Wait = *seconds from now until midnight calculated in your algorithm up there* varScheduleTime = TimeStamp() + Wait <-- this will store the Unix time of tomorrow @midnight RemoveNotifications(...) RunAt(varScheduleTime,...,...) Actually, I think I'll revise mine to work like that! I have an script that uploads two backups to my FTP server every day. The idea is that I can be up and running immediately if my phone is lost/stolen! |
|
||||
|
Re: Certain script run at a certain time
It's all the same thing lol. I couldn't see it until I tried simplifying it to give the cpu fewer calculations to perform.
Code:
GetTime(varH,varM,varS) varSecondsUntilMidnight = ((23-varH)*3600) + (59-varM)*60) + (60-varS)) varMidnightUnix = TimeStamp() + varSecondsUntilMidnight Code:
GetTime(varH,varM,varS) varSecondsUntilMidnight = 86400 - (varH*3600) - (varM*60) - varS varMidnightUnix = TimeStamp() + varSecondsUntilMidnight Code:
GetTime(varH,varM,varS) varMidnightUnix = TimeStamp() + 86400 - (varH*3600) - (varM*60) - varS |
|
||||
|
Re: Certain script run at a certain time
Quote:
|
|
||||
|
Re: Certain script run at a certain time
Yeah follows regular order of operations. I have a pair of extra parantheses above just to make it easier to read, so you can ignore that.
Also, you need to use (23-varH) otherwise you'll end up with 25hr days. Try it with 22:30... if you use 24 for the number of hours, the result will 2.5hrs until midnight You can always do use Message() to display the current value of variables for testing and troubleshooting, something like Message("hours= " & varH) or even Message(TimeStamp()) !! |
|
||||
|
Re: Certain script run at a certain time
Quote:
|
|
||||
|
Re: Certain script run at a certain time
If it works, it works! Just make sure to double-check your time and you're golden
|
![]() |
|
|
|