PPCGeeks

PPCGeeks (http://forum.ppcgeeks.com/index.php)
-   HTC Touch Pro 2 (http://forum.ppcgeeks.com/forumdisplay.php?f=97)
-   -   Certain script run at a certain time (http://forum.ppcgeeks.com/showthread.php?t=142666)

elesbb 04-12-2011 09:30 AM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by quick99si (Post 2083654)
Tell me if this helps (I apologize in advance for the lengthy notes!).

that's perfection .. You rock , wish I could hit the thanks button a million times . You have no idea how much you have clariied things for me , don't ever apologize for lengthly notes ! they help so much ! I created my own script but the coding is exactly like yours , just different variable names . One thing I also was able to use , was this :
Code:

GetTime(Hour,x,y)
Wait=(24-Hour)
Wait=(Wait*3600)
x=60-x
x=x*60
Wait =Wait+x
Wait=Wait*1000
Sleep(Wait)
Run("\Program Files\elesbb\Set Sleep Time\Sleep 5 Seconds.mscr")
exit

this works for what I want it to do .. But having it in the notification queue . I feel that would be best .
Thanks so much for clarifing everything , and making things understandable !
in my java programming course , he makes us wright an algorithm before any code is allowed to be written , I tried that with this mort script , but not fully understanding the code and unix timestamp crap , I failed . Lol .
Seriously , I can't say thanks enough .

quick99si 04-12-2011 10:29 AM

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!

quick99si 04-12-2011 11:05 AM

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


elesbb 04-12-2011 11:36 AM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by quick99si (Post 2083712)
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


haha ! yes . and make sure if you want midnight , to make it 24 , not 23 , hence , 24 hours in a day . and you can actually use that for any time , say you want it at 10 , then you would use 22 , I kinda like this method too , I really don't think the memory usage is all that high , but if I shut off my phone or restart , the script ends , where your first version , gets saved in the notification queue . and just a random question , does Mort script follow order of operations ?

quick99si 04-12-2011 12:35 PM

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()) !!

elesbb 04-12-2011 12:54 PM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by quick99si (Post 2083744)
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()) !!

hmm , I have used message to display variable values , however , the amount of time until midnight was wrong , unless I used 24 .. maybe I'm doing something wrong ?

quick99si 04-12-2011 01:37 PM

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 :)

elesbb 04-12-2011 06:54 PM

Re: Certain script run at a certain time
 
yes sir ! thanks so much for all your help !


All times are GMT -4. The time now is 04:41 PM.

Powered by vBulletin® ©2000 - 2025, Jelsoft Enterprises Ltd.
©2012 - PPCGeeks.com


Content Relevant URLs by vBSEO 3.6.0