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.


All times are GMT -4. The time now is 03:02 AM.

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


Content Relevant URLs by vBSEO 3.6.0