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-10-2011 10:07 AM

Certain script run at a certain time
 
What i want to do is RUn a script at midnight every night . How can i do this ?

I was looking through the MortScript manual and found a command named "RunAt" but was very confused as to the formating and syntax of this command . Im just confused as to how this command works . any examples from those who better understand mortscript would be appreciated :)

I personally would like HELP as to accomplish this rather than someone doing it for me , i want to better learn and understand mortscript.

THANKS GUYS !!

PPCFreak 04-10-2011 10:25 AM

Wirelessly posted (VZW TP2: Opera/9.7 (WindowsMobile; PPC; Opera Mobi/35267; U; en; Presto/2.1.1))

wrong section
Will get better response if this was in the main threads....
That said, what are you looking for on Mortscript?
RunAt has a date and time parameters. look online for mortscript manual. It has samples for RunAt and all the other commands in Mortscript.

elesbb 04-10-2011 11:14 AM

Re: Certain script run at a certain time
 
I just noticed I posted in the wrong section . I forgot I was in the rom section when I posted . I just wasn't paying attention . I already have the MortScript manual . I just don't completely understand the formats used for the date and time functions .

darren.wlsn1 04-10-2011 12:24 PM

Re: Certain script run at a certain time
 
moved..

elesbb 04-10-2011 01:45 PM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by darren.wlsn1 (Post 2082880)
moved..

thank you . I had a brain fart this morning and wasn't paying attention .

darren.wlsn1 04-10-2011 07:04 PM

Quote:

Originally Posted by elesbb (Post 2082912)
thank you . I had a brain fart this morning and wasn't paying attention .

Not a problem.

Sent from my SPH-D700 using Tapatalk

mwalt2 04-10-2011 08:34 PM

Re: Certain script run at a certain time
 
Search and ask in the thread below. I don't know the answer, but I'm sure it can probably be done.

MortScript examples accumulation - xda-developers

elesbb 04-10-2011 09:52 PM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by mwalt2 (Post 2083049)
Search and ask in the thread below. I don't know the answer, but I'm sure it can probably be done.

MortScript examples accumulation - xda-developers

I'm pretty sure its possible . I've been on that thread more than I'm in my own underwear . its helpful , but a lot of the examples are old style code . but thank you ! I'll dig around in there ! *gets shovel*

NinjaDuck 04-10-2011 11:43 PM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by elesbb (Post 2082860)
What i want to do is RUn a script at midnight every night . How can i do this ?

I was looking through the MortScript manual and found a command named "RunAt" but was very confused as to the formating and syntax of this command . Im just confused as to how this command works . any examples from those who better understand mortscript would be appreciated :)

I personally would like HELP as to accomplish this rather than someone doing it for me , i want to better learn and understand mortscript.

THANKS GUYS !!

GAlarm - is a great alarm clock and also lets you schedule programs to run instead of alarms. Well worth the $$.

quick99si 04-11-2011 06:36 AM

Re: Certain script run at a certain time
 
Forget taking it elsewhere, we can solve it here ;)

I know you said you just wanted help and not a solution, but first, I'm assuming you've referred to the *complete* manual? You can download it in HTML for viewing on your phone, use this clickable PDF: http://www.sto-helit.de/downloads/mo...ipt-Manual.pdf, etc..

For your scheduling needs, you can would make the notification from within the script that is being scheduled. Before doing this, I advise removing the script from the Windows notifications queue first using the following command:

Code:

RemoveNotifications(applications, parameter)
For application, you'll reference MortScript.exe (full path), and for the parameter, you will need the full path and filename of your script in quotes. SystemPath() is used for both. That command ensures that you won't leave duplicates in the queue.

As far as scheduling the execution, it's not as straightforward and frankly, I'm still thinking of the most elegant way myself. My elementary instict was to do something like:

Code:

GetTime(varTmp,varTmp,varTmp,varDay,varMonth,varYear)
varSelf=SystemPath("ScriptPath") + SystemPath("ScriptName") + SystemPath("ScriptExt") +
RunAt(varYear,varMonth,varDay+1,"0","01",varSelf)

But the problem arises with the day+1 computation... it won't work all that well on April 30th trying to schedule itself for 04-31-2011 00:01, then 4-32, 4-33, etc... You would need to use some if statements but it gets ugly with the different number of days or different months, and so on.

The way around this is to use Unix timestamp and time formatting.

Code:

9.11.2  Formatted output (FormatTime)
string = FormatTime( format [, timestamp ] )
Returns the time of the timestamp, or the current time if none is given, formatted corresponding to
the format string.
These characters will be replaced with the corresponding value:
H Hour (00-23)
h Hour (01-12)
a am/pm
A AM/PM
i Minute (00-59)
s Seconds (00-59)
d Day (01-31)
m Month (01-12)
Y Year (4 digits)
y Year (2 digits)
w Day of week (0=Sunday to 6=Saturday)
u Unix timestamp
{MM}Month name (e.g. “January”)
{M} Month name abbreviated (e.g. “Jan”)
{WW}Day of week name (e.g. “Monday”)
{W} Day of week name abbreviated (e.g. “Mon”)
All other characters remain unchanged.
Note all return values will be strings. This is to allow leading zeroes, like "02" for february, which
is handy to combine filenames. However, it might cause troubles when using arrays. You either
need to assign the array elements with strings (“Month["01"] = "First"”) or convert the string to a
number, e.g. by using “FormatTime("m")*1”.
Examples:
x = FormatTime( "h:i:s a" )
x = FormatTime( "m/d/Y", TimeStamp() + 86400 )

The last line adds exactly 24hours to the current time and returns it in "04/12/2011" format. That's a bit useless to you since you'd have to parse it further. Instead, I would advise passing "u" as the format and then using that value with RunAt() for scheduling the next execution.
Code:

9.6.5  Execute application at a given time (RunAt):
RunAt( Unix timestamp, application [, parameter] )

Again, application is the Mortscript EXE and parameter is your script in quotes. The only concern I have is that if you keep rescheduling the script for 24hrs in the future, you may start seeing time added due to delays in the event that your phone is off at that time and the script is execute 6hrs late or something. Therefore, the unix timesamp() + 24hrs thing is only effective for extracting the date of the next day (not the time).

So the final hurdle involves getting tomorrow's time in Unix format, converting that time to a regular time format, changing that new time to 00:01 while leaving the d/m/y intact, change it back to Unix, and then pass that value to RunAt().

There are a couple of different ways of doing it, I'll post mine when I sit down and get my script finalized. I'd like to see what you come up with as well.

quick99si 04-11-2011 07:47 AM

Re: Certain script run at a certain time
 
Here's what I put together, it's semi-tested:
Code:

varAutoRunTime="00:01"
 
varSelf = SystemPath("ScriptPath") \ SystemPath("ScriptName") & SystemPath("ScriptExt")
varMort = SystemPath("ScriptExe") \ "MortScript.exe"
 
varAutoRunTimeH = part(varAutoRunTime,":",1)
varAutoRunTimeM = part(varAutoRunTime,":",2)
 
If(varAutoRunTimeH < 0 OR varAutoRunTimeH > 23 OR varAutoRunTimeM < 0 OR varAutoRunTimeM > 60)
  varAutoRunTimeH="07"
  varAutoRunTimeH="00"
EndIf
 
varTomorrow = TimeStamp()+86400
varTomorrowMidnight = varTomorrow - (FormatTime("H",varTomorrow)*3600) - (FormatTime("i",varTomorrow)*60) - (FormatTime("s",varTomorrow))
varTomorrowSchedule = varTomorrowMidnight + (varAutoRunTimeH*3600) + (varAutoRunTimeM*60)

You can combine the last 3 lines into one i you'd like. I just posted it that way to make it more legible online.

And then for the notification queue:
Code:

RemoveNotifications(varMort,"""" & varSelf & """")
RunAt(varTomorrowSchedule,varMort,"""" & varSelf & """")


elesbb 04-11-2011 10:22 AM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by NinjaDuck (Post 2083107)
GAlarm - is a great alarm clock and also lets you schedule programs to run instead of alarms. Well worth the $$.


I use this , however , i also have pocketshield . and i have the reg entry SLEEPTIME set to 5 so when i get a text while my phones in my pocket it will screen off in 5 seconds . unfourtunatly , when i have my alarm go off , 5 seconds isnt enough for pocketshield to unlock itself once galarm powers up (have galarm in the exceptions list) so at midnight , i want to run a script that will reset the SLEEPTIME reg entry to 30 . Thanks though !

elesbb 04-11-2011 10:50 AM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by quick99si (Post 2083221)
Forget taking it elsewhere, we can solve it here ;)

I know you said you just wanted help and not a solution, but first, I'm assuming you've referred to the *complete* manual? You can download it in HTML for viewing on your phone, use this clickable PDF: http://www.sto-helit.de/downloads/mo...ipt-Manual.pdf, etc..

For your scheduling needs, you can would make the notification from within the script that is being scheduled. Before doing this, I advise removing the script from the Windows notifications queue first using the following command:

Code:

RemoveNotifications(applications, parameter)
For application, you'll reference MortScript.exe (full path), and for the parameter, you will need the full path and filename of your script in quotes. SystemPath() is used for both. That command ensures that you won't leave duplicates in the queue.

As far as scheduling the execution, it's not as straightforward and frankly, I'm still thinking of the most elegant way myself. My elementary instict was to do something like:

Code:

GetTime(varTmp,varTmp,varTmp,varDay,varMonth,varYear)
varSelf=SystemPath("ScriptPath") + SystemPath("ScriptName") + SystemPath("ScriptExt") +
RunAt(varYear,varMonth,varDay+1,"0","01",varSelf)

But the problem arises with the day+1 computation... it won't work all that well on April 30th trying to schedule itself for 04-31-2011 00:01, then 4-32, 4-33, etc... You would need to use some if statements but it gets ugly with the different number of days or different months, and so on.

The way around this is to use Unix timestamp and time formatting.

Code:

9.11.2  Formatted output (FormatTime)
string = FormatTime( format [, timestamp ] )
Returns the time of the timestamp, or the current time if none is given, formatted corresponding to
the format string.
These characters will be replaced with the corresponding value:
H Hour (00-23)
h Hour (01-12)
a am/pm
A AM/PM
i Minute (00-59)
s Seconds (00-59)
d Day (01-31)
m Month (01-12)
Y Year (4 digits)
y Year (2 digits)
w Day of week (0=Sunday to 6=Saturday)
u Unix timestamp
{MM}Month name (e.g. “January”)
{M} Month name abbreviated (e.g. “Jan”)
{WW}Day of week name (e.g. “Monday”)
{W} Day of week name abbreviated (e.g. “Mon”)
All other characters remain unchanged.
Note all return values will be strings. This is to allow leading zeroes, like "02" for february, which
is handy to combine filenames. However, it might cause troubles when using arrays. You either
need to assign the array elements with strings (“Month["01"] = "First"”) or convert the string to a
number, e.g. by using “FormatTime("m")*1”.
Examples:
x = FormatTime( "h:i:s a" )
x = FormatTime( "m/d/Y", TimeStamp() + 86400 )

The last line adds exactly 24hours to the current time and returns it in "04/12/2011" format. That's a bit useless to you since you'd have to parse it further. Instead, I would advise passing "u" as the format and then using that value with RunAt() for scheduling the next execution.
Code:

9.6.5  Execute application at a given time (RunAt):
RunAt( Unix timestamp, application [, parameter] )

Again, application is the Mortscript EXE and parameter is your script in quotes. The only concern I have is that if you keep rescheduling the script for 24hrs in the future, you may start seeing time added due to delays in the event that your phone is off at that time and the script is execute 6hrs late or something. Therefore, the unix timesamp() + 24hrs thing is only effective for extracting the date of the next day (not the time).

So the final hurdle involves getting tomorrow's time in Unix format, converting that time to a regular time format, changing that new time to 00:01 while leaving the d/m/y intact, change it back to Unix, and then pass that value to RunAt().

There are a couple of different ways of doing it, I'll post mine when I sit down and get my script finalized. I'd like to see what you come up with as well.


Alright , thank you so much for this .. im still fuzzy , however i started wondering into the mist . Where before i was too confused to even start . the mist was a dense fog where i couldnt even see my footing .

I noticed you put up your own script , ill try my version today . may not get it done , have a research paper to wright , but ill try my best ! Thanks again so very much !!!! :D :toothy7:

quick99si 04-11-2011 11:39 AM

Re: Certain script run at a certain time
 
I tested it in my FTP Backup script and it works/schedules perfectly fine so far :)

elesbb 04-11-2011 12:42 PM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by quick99si
Code:

varAutoRunTime="00:01"

varSelf = SystemPath("ScriptPath") \ SystemPath("ScriptName") & SystemPath("ScriptExt")
varMort = SystemPath("ScriptExe") \ "MortScript.exe"

varAutoRunTimeH = part(varAutoRunTime,":",1)
varAutoRunTimeM = part(varAutoRunTime,":",2)

If(varAutoRunTimeH < 0 OR varAutoRunTimeH > 23 OR varAutoRunTimeM < 0 OR varAutoRunTimeM > 60)
varAutoRunTimeH="07"
varAutoRunTimeH="00"
EndIf

varTomorrow = TimeStamp()+86400
varTomorrowMidnight = varTomorrow - (FormatTime("H",varTomorrow)*3600) - (FormatTime("i",varTomorrow)*60) - (FormatTime("s",varTomorrow))
varTomorrowSchedule = varTomorrowMidnight + (varAutoRunTimeH*3600) + (varAutoRunTimeM*60)


can you possibly put comments as to what each line is doing ? i think i understand the whole timestamp and unix format .. i beilieve with the IF statement you are ensuring it to be at MIDNIGHT , considering TimeStamp get the amount of seconds FROM 01/01/1970 ...

mwalt2 04-11-2011 10:43 PM

Re: Certain script run at a certain time
 
This is off topic as far as mortscript is concerned, but I've also been having problems with g-alarm since I bought pocketshield. elesbb, are you able to use the g-sensor in g-alarm (like shake to snooze) with pocketshield installed? Even though I don't use any g-sensor settings in pocketshield, it still snoozes g-alarm almost instantly after the alarm goes off. Removing pocketshield makes it so this isn't a problem anymore, so it must be doing something. I've also had problems with it turning off g-alarm too soon as you have had (with the g-sensor setting in g-alarm disabled).

elesbb 04-11-2011 11:10 PM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by quick99si (Post 2083296)
I tested it in my FTP Backup script and it works/schedules perfectly fine so far :)

thank you !

one quick question , when the command runAt is executed , does the script that executes that command need to be ran again ? or does the device know when to run the desired program automatically after you execute the script ?

like in the code you listed , it uses the variable (varTomorrowSchedule) to tell the runAt command when to launch specified program , mus the script be constantly ran to reassign the value of varTomorrowSchedule ? or once you run the script once that's it ? thanks again man . You rock !

elesbb 04-11-2011 11:24 PM

Re: Certain script run at a certain time
 
1 Attachment(s)
Quote:

Originally Posted by mwalt2 (Post 2083556)
This is off topic as far as mortscript is concerned, but I've also been having problems with g-alarm since I bought pocketshield. elesbb, are you able to use the g-sensor in g-alarm (like shake to snooze) with pocketshield installed? Even though I don't use any g-sensor settings in pocketshield, it still snoozes g-alarm almost instantly after the alarm goes off. Removing pocketshield makes it so this isn't a problem anymore, so it must be doing something. I've also had problems with it turning off g-alarm too soon as you have had (with the g-sensor setting in g-alarm disabled).

1st , make sure you have galarm added to the aplication exceptions list found under the unlocking tab (see attatched) in order for pocketshield to allow the alarm to sound .

the problem I have experienced ,
I personally found the reg entry which handles the time the screen stays on once it wakes up , while its still locked . I changed it to 5 , allowing me to save battery when I get a text message and my phones in my pocket . Since it doesn't screen off from the proximity sensor . However , when my device wakes for an alarm , the galarm application doesn't fully load in 5 seconds to the point where pocketshield notices it as an active application and shuts the screen off keeping the alarm from sounding until the screen turns on again . But when I have the sleep time set to 30 seconds , it unlocks due to the exception added for galarm , and my alarm sounds like its supposed to .

so I have 2 mortscripts written which allows me to change the sleep time without using resco or any other reg editor . And what I wanted to do was have each script run at a certain time , like for me , have the 30 second script run at midnight , so my alarm goes off at 6 when I wake up , then having the 5 second script run to restore the 5 second sleep at say 630 when I have already woken .

if your device is unlocked , the g sensor should function correctly with galarm , I haven't experienced any issues when it unlocks to sound the alarm . Let me know if you get it working or what other problems you run into .

quick99si 04-12-2011 06:35 AM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by elesbb (Post 2083327)
can you possibly put comments as to what each line is doing ? i think i understand the whole timestamp and unix format .. i beilieve with the IF statement you are ensuring it to be at MIDNIGHT , considering TimeStamp get the amount of seconds FROM 01/01/1970 ...


Tell me if this helps (I apologize in advance for the lengthy notes!).

Quote:

varAutoRunTime="00:01" <--- this is a variable that stores a time for daily execution. Doing this lets you easily adapt it to other scripts. You can change this to anything you want really, like 06:00 for 6AM or 18:30 for 6PM. I don't recommend 00:00 because the phone updates the calendar at that time every day. Most of my scripts are at 3AM, 6AM, etc..

varSelf = SystemPath("ScriptPath") \ SystemPath("ScriptName") & SystemPath("ScriptExt")
varMort = SystemPath("ScriptExe") \ "MortScript.exe" <--- these two variables just point to the Mortscript shell exe and your own script. It's used later to schedule a notification.

varAutoRunTimeH = part(varAutoRunTime,":",1)
varAutoRunTimeM = part(varAutoRunTime,":",2) <--- extract 2 integers from the time setting above using the colon as the separator. the H variable will have something like "00" and M will have "01" (1 minute past midnight).

If(varAutoRunTimeH < 0 OR varAutoRunTimeH > 23 OR varAutoRunTimeM < 0 OR varAutoRunTimeM > 60)
varAutoRunTimeH="07"
varAutoRunTimeH="00" <---making sure that we didn't set the time incorrectly in the first line above. H has to be between 0 and 23 inclusive, while M has to be between 0 and 59 inclusive. I guess I should have a 59 instead of a 60 in this line actually, but they'll work identically for our purposes. If you set the first line above to something like 24:70, it'll default to 7AM (07:00) because it assumes you've made a mistake. These two lines are totally optional obviously.
EndIf

varTomorrow = TimeStamp()+86400 <--- this points to a time exactly 24hrs from now. TimeStamp() returns the current time and 86400 is added, which translates to 24hrs in seconds. The time is in Unix format (seconds since 1/1/70). We need to use the Unix format so we can avoid dealing with figuring out tomorrow's date (no need to roll over months, years, Feb issues, etc..).

varTomorrowMidnight = varTomorrow - (FormatTime("H",varTomorrow)*3600) - (FormatTime("i",varTomorrow)*60) - (FormatTime("s",varTomorrow)) <--- this line computes the Unix time of tomorrow's date at midnight. It's basically tomorrow's time (24hr in the future), minus the hours/minutes/seconds past midnight so it's adjusted to 0:00:00 of tomorrow's date. If the current time is 04-12-2011 6AM, varTomorrowMidnight will add 24hrs to the current time and then subtract 6hrs (21600 seconds). The result is 04-12-2011 0:00 in Unix format.

varTomorrowSchedule = varTomorrowMidnight + (varAutoRunTimeH*3600) + (varAutoRunTimeM*60)<--- this line basically uses tomorrow's midnight time and adds whatever we set in the first line above. For you, if you're using 00:01 up there, it'll only add 1 minute (60 seconds) to varTomorrowMidnight. You can see that you can combine this line with the previous if you'd like to optimize the script - no need to go back to midnight, and then forward to a scheduled time.

quick99si 04-12-2011 06:42 AM

Re: Certain script run at a certain time
 
Quote:

Originally Posted by elesbb (Post 2083572)
thank you !

one quick question , when the command runAt is executed , does the script that executes that command need to be ran again ? or does the device know when to run the desired program automatically after you execute the script ?

like in the code you listed , it uses the variable (varTomorrowSchedule) to tell the runAt command when to launch specified program , mus the script be constantly ran to reassign the value of varTomorrowSchedule ? or once you run the script once that's it ? thanks again man . You rock !

Yes, it does. The RunAt() command can only schedule one notification at a time, so the commands above must be left in the script in order to have it schedule its notification on its own.

The first time you run it will be manual and it will add itself to the notification queue for tomorrow at midnight. When it runs at that time, it'll add itself to the queue on the following day at midnight, and so on.

You can actually see all the notifications on your device using dotFred's Task Manager (to verify that your script is working or the delete/add notifications manually). He's the author of PIMBackup and they're both fantastic programs IMO. Check out his site at: Dotfred's TaskMgr

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 02:35 PM.

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


Content Relevant URLs by vBSEO 3.6.0