AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SetTimer small wish
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
majkinetor



Joined: 24 May 2006
Posts: 3622
Location: Belgrade

PostPosted: Fri May 18, 2007 5:37 pm    Post subject: SetTimer small wish Reply with quote

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
View user's profile Send private message MSN Messenger
Titan



Joined: 11 Aug 2004
Posts: 5041
Location: imaginationland

PostPosted: Fri May 18, 2007 5:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
raven-gm



Joined: 25 Mar 2007
Posts: 24

PostPosted: Fri May 18, 2007 6:33 pm    Post subject: Reply with quote

Titan wrote:
Support++

Laughing
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
View user's profile Send private message AIM Address
corrupt



Joined: 29 Dec 2004
Posts: 2393

PostPosted: Fri May 18, 2007 7:14 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Titan



Joined: 11 Aug 2004
Posts: 5041
Location: imaginationland

PostPosted: Fri May 18, 2007 7:40 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
corrupt



Joined: 29 Dec 2004
Posts: 2393

PostPosted: Fri May 18, 2007 8:55 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3622
Location: Belgrade

PostPosted: Fri May 18, 2007 9:45 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
corrupt



Joined: 29 Dec 2004
Posts: 2393

PostPosted: Fri May 18, 2007 10:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat May 19, 2007 9:51 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
majkinetor



Joined: 24 May 2006
Posts: 3622
Location: Belgrade

PostPosted: Sat May 19, 2007 10:10 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sat May 19, 2007 11:35 am    Post subject: Reply with quote

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... Smile
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3622
Location: Belgrade

PostPosted: Sat May 19, 2007 11:40 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
corrupt



Joined: 29 Dec 2004
Posts: 2393

PostPosted: Sat May 19, 2007 4:31 pm    Post subject: Reply with quote

majkinetor wrote:
Thats why things like this one are called syntax suggars.
Syntactic sugar
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3622
Location: Belgrade

PostPosted: Sat May 19, 2007 4:49 pm    Post subject: Reply with quote

oh, sry, syntactic sugar.

Now everybody know exactly what it is.
_________________
Back to top
View user's profile Send private message MSN Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Wed May 30, 2007 1:24 pm    Post subject: Reply with quote

SetTimer has been improved to treat negative periods as "run only once". Thanks for the idea.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group