 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Akize
Joined: 16 Jan 2006 Posts: 34
|
Posted: Sat Dec 30, 2006 4:31 am Post subject: Simpler way to store data besides arrays? (for a scheduler) |
|
|
I need my PC to do certain actions throughout the day and am writing a short scheduling program to do it.
I'm going about this problem by dumping the schedule into a txt file in this format:
day of week,time,task1
day of week,time,task2
etc.
Then I have the script loop every 15 seconds and if the day of week and time matches the current day of week and time, then I'll run the task.
However I'm used to PHP / C++ where I'll just the dump the information into arrays / matrices and accessing it that way, but arrays in AHK are messy. Outside of accessing and parsing the text file every 15 seconds, is there a more efficient method of data retention / access? |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Sat Dec 30, 2006 10:34 am Post subject: |
|
|
Well, you can use WinXP's task scheduler for that... Or some similar freeware.
Otherwise, you need to read it only once, don't you? Or just put the info in a continuation section, if you don't mind editing the script to change the data. You have to reload the script anyway, after changing data (or have some hotkey to re-read the text file).
Of course, in both case, you have to parse the info on every timer tick, but it should be fast enough to be transparent.
I wish to have true arrays / associative arrays too, I am working on a proposal toward this, but it won't be soon... _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1160 Location: Denmark
|
Posted: Sat Dec 30, 2006 10:39 am Post subject: |
|
|
To avoid parsing the file each time use the flags as in
http://www.autohotkey.com/forum/viewtopic.php?t=135&highlight=archive. _________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Sat Dec 30, 2006 10:44 am Post subject: |
|
|
I believe the problem was less on accessing the data than on storing it efficiently in AHK.
Note that using AHK pseudo-arrays isn't that bad... For example, you can use day of week & time info as index, if properly formated. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1160 Location: Denmark
|
Posted: Sat Dec 30, 2006 11:24 am Post subject: |
|
|
I just remembered this cron-clone: http://www.kalab.com/freeware/pycron/pycron.htm.
Cron is the name of the task scheduler on unix system and works on a configuration file.
The configuration are somewhat more advanced than Akazi´s example. _________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
Akize
Joined: 16 Jan 2006 Posts: 34
|
Posted: Sat Dec 30, 2006 5:46 pm Post subject: |
|
|
Thanks for all the responses.
| PhiLho wrote: | | Well, you can use WinXP's task scheduler for that... Or some similar freeware. |
LOL I had completely forgotten about Windows task scheduler. Well at the moment I'm only running apps, but in the near future there will be a need for sending keystrokes / mouse clicks to the computer.
| Quote: | | Otherwise, you need to read it only once, don't you? |
Just once, unless the schedule file has changed but that's easy enough to check for.
| Quote: | | Or just put the info in a continuation section, if you don't mind editing the script to change the data. You have to reload the script anyway, after changing data (or have some hotkey to re-read the text file). |
I would prefer not having to reload the script every time I change data / embed the data into the script. How would you use a continuation section to hold the data? Right now I'm just parsing the data every 15 seconds.
| Quote: | Of course, in both case, you have to parse the info on every timer tick, but it should be fast enough to be transparent.
|
Currently it's the schedule is small enough that the parsing is fast enough to be transparent, but I'm worried about the future / scalability.
| Quote: | | I wish to have true arrays / associative arrays too, I am working on a proposal toward this, but it won't be soon... |
Well one can always hope.
Phil's correct, my main problem is data retention, not accessability.
| tonne wrote: | I just remembered this cron-clone: http://www.kalab.com/freeware/pycron/pycron.htm.
Cron is the name of the task scheduler on unix system and works on a configuration file.
The configuration are somewhat more advanced than Akazi´s example. |
This definately looks very useful, thanks a lot for the suggestion. I would've preferred to have the scheduler and all actions in one program, but pycron looks good enough that I may just script the actions seperately and have pycron schedule the events. I don't remember what happened, but I just don't trust Windows Task Scheduler that much. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Sun Dec 31, 2006 11:00 am Post subject: |
|
|
| Akize wrote: | | LOL I had completely forgotten about Windows task scheduler. Well at the moment I'm only running apps, but in the near future there will be a need for sending keystrokes / mouse clicks to the computer. [...] I just don't trust Windows Task Scheduler that much. | Why? To use Send, just run some AHK script...
| Quote: | | How would you use a continuation section to hold the data? Right now I'm just parsing the data every 15 seconds. | Well, it won't save you the parsing, but the loading. Parsing data each time should not be a problem every 15s... Not slower than parsing it once, putting data in a pseudo-array and walking the array each time...
| Quote: | | [pycron] definately looks very useful, thanks a lot for the suggestion. | There are other cron clones, I searched them a while ago. Search cron in the Utilities section, you will find two related topics, but not exhaustive. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|