| View previous topic :: View next topic |
| Author |
Message |
majkinetor
Joined: 24 May 2006 Posts: 3622 Location: Belgrade
|
Posted: Fri May 18, 2007 5:37 pm Post subject: SetTimer small wish |
|
|
It would be very convenient if we had option to execute timer only once.
For instance:
| Code: | | OnTimer, MyFunc, 250,,1 |
or
| Code: | | OnTimer, MyFunc, -250 |
This would be equivalent to:
| Code: | MyFunc:
OnTimer, MyFunc, off
...
return |
Such option exists in many languages, not via Timer though.
For instance JS frameworks we have delay function, to exected function with delay
| Code: | | func(...).delay(400) |
_________________
 |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5041 Location: imaginationland
|
Posted: Fri May 18, 2007 5:54 pm Post subject: |
|
|
Support++ _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
raven-gm
Joined: 25 Mar 2007 Posts: 24
|
Posted: Fri May 18, 2007 6:33 pm Post subject: |
|
|
Support += A_Lot _________________ I would like to think that I know what I'm doing, but there's just to much stuff I've yet to learn... |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2393
|
Posted: Fri May 18, 2007 7:14 pm Post subject: |
|
|
Why not turn the timer off at the end of the timer routine? I'm not sure I understand the request. Could you please give a better example? If you need to run a timer once, you can turn the timer off just before the Return line. This can also be done conditionally. If you just need a delay before executing something then you can use Sleep. If you're using a timer only to start a separate thread then that seems like a separate request. Maybe I'm misunderstanding...
Also, why OnTimer ? It sounds more like a notification event than a command.
<Avaiting flaming response from majkinetor now...> |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5041 Location: imaginationland
|
Posted: Fri May 18, 2007 7:40 pm Post subject: |
|
|
JavaScript has setTimeout/setInterval and this would be like an extension of both. It's another convenience thing. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2393
|
Posted: Fri May 18, 2007 8:55 pm Post subject: |
|
|
| Titan wrote: | | It's another convenience thing. | That's something that I find interesting... Why the frequent flood of requests for convenience features (most that will only save a line or 2 of code) vs requests for additional functionality when Chris has mentioned that he has a large backlog of items on the todo list that might take years to complete at the current rate? |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3622 Location: Belgrade
|
Posted: Fri May 18, 2007 9:45 pm Post subject: |
|
|
If that can be done in an hour, why not ?
New Features are usualy measured in weeks, not hours
Anyway, U can always programm in ASM if you want no syntax suggars and lot of code. _________________
 |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2393
|
Posted: Fri May 18, 2007 10:19 pm Post subject: |
|
|
| majkinetor wrote: | | If that can be done in an hour, why not ? | ...because it all adds up and likely stresses the energy budget... Many things can be done in an hour but it doesn't mean that they should take priority so why not request items that should have priority instead of things that will save 10 seconds of typing when writing a script? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat May 19, 2007 9:51 am Post subject: |
|
|
Although I'm not in favor of adding "OnTimer" at this time (since that would be costly in code size and development time), SetTimer could be altered to accept negative periods. Such a period would mean "run this timer only once".
This would be easy to add; but I'm not sure the convenience it provides is enough to justify it. What do you think? |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3622 Location: Belgrade
|
Posted: Sat May 19, 2007 10:10 am Post subject: |
|
|
I think you should think no more. Negative timer is good, and much better then using additional param. I told you already it is common around to have that, as you tend to ask that question when judging value of something. _________________
 |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Sat May 19, 2007 11:35 am Post subject: |
|
|
Convenience functionalities might have a lower priority than real features, but that's what makes a language friendly... Almost everything can be done i current AHK, but some things are lengthly and error prone.
If they are very easy to implement (like the negative value), and need little to add to the doc, it worth considering.
This wish reminds me of the ToolTip time-out wish, still in the pending list: we often want to show a tooltip for a given time, and the workaround shown in the manual is to use a timer, which is annoying because you have to add 5 lines and a label just for this. At least this wish will remove one line...  _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3622 Location: Belgrade
|
Posted: Sat May 19, 2007 11:40 am Post subject: |
|
|
| Quote: | | At least this wish will remove one line... |
Its not how many lines it removes but how frequent it is used.
Tooltips are not so frequent as executing timer only once... I see timer switched off on first run almost every second case. So, in long run, it saves more then Tooltip example
Anyway, small thigs like this one, make language beautiful. Thats why things like this one are called syntax suggars.
With negative timer value, I think this can be done in 10 minutes, thats why I proposed it originaly. _________________
 |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2393
|
Posted: Sat May 19, 2007 4:31 pm Post subject: |
|
|
| majkinetor wrote: | | Thats why things like this one are called syntax suggars. | Syntactic sugar |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3622 Location: Belgrade
|
Posted: Sat May 19, 2007 4:49 pm Post subject: |
|
|
oh, sry, syntactic sugar.
Now everybody know exactly what it is. _________________
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed May 30, 2007 1:24 pm Post subject: |
|
|
| SetTimer has been improved to treat negative periods as "run only once". Thanks for the idea. |
|
| Back to top |
|
 |
|