Since when was sleep an expression in v1???

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
iseahound
Posts: 1445
Joined: 13 Aug 2016, 21:04
Contact:

Since when was sleep an expression in v1???

25 Sep 2021, 20:06

I remember doing Sleep % 30 + 5000. When did this change?
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Since when was sleep an expression in v1???

25 Sep 2021, 20:10

lol
you can do the same with mousemove and others

That right there is why people moan about inconsistencies in ahk lol
User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: Since when was sleep an expression in v1???

25 Sep 2021, 20:18

The trend is useful, as it seems that most of the parameters that are expected to be numeric can be an expression as well.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Since when was sleep an expression in v1???

25 Sep 2021, 20:31

1.0.25 - January 12, 2005 wrote:Added support for expressions in commands that have numeric parameters, such as StringLeft. In addition, IF-statements may use complex expressions by including a parenthesis as the first character, e.g. if (X < Y + 10) and (Color = "Blue"). Finally, Var:=expression has been added to assign the result of an expression to a variable, e.g. Var := 100*X + 1/3. See Expressions for details about operators, string concatenation, and easier access to arrays. [thanks Joost Mulders]
well over 16 years ago, apparently
iseahound
Posts: 1445
Joined: 13 Aug 2016, 21:04
Contact:

Re: Since when was sleep an expression in v1???

25 Sep 2021, 21:28

I don't believe it. All the code on this forum uses Sleep % expr. I was only porting from v2 to v1 that I realized it works.

https://autohotkey.com/board/topic/39023-sleep-var/
tidbit wrote: j:= ;your equation/expression here, can include variables as well.
sleep, %j%
or
sleep, % ;your equation/expression here, can include variables as well. include 1 space after the %
like that?
https://autohotkey.com/board/topic/68028-sleep-variable/
https://autohotkey.com/board/topic/111988-using-a-global-variable-to-modify-sleep-length/
https://autohotkey.com/board/topic/99171-sleep-variable-not-working/
viewtopic.php?t=66300
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Since when was sleep an expression in v1???

25 Sep 2021, 21:45

well i must come clean and say i wasnt very diligent in checking this, i just went off of what was documented. it may have been possible to do this even earlier than that. luckily for u, most all interpreters are available, so u can try it out on ur own
lexikos
Posts: 9589
Joined: 30 Sep 2013, 04:07
Contact:

Re: Since when was sleep an expression in v1???

25 Sep 2021, 22:46

:lol:

Numeric Parameters

Numeric parameters accept a literal number or an expression, and can be identified by phrasing like "This parameter can be an expression."

For historical reasons, simple variable references alone or combined with digits are not interpreted as expressions. For example:

Code: Select all

Sleep %n%000  ; Sleep for n seconds.
Sleep %m%     ; Sleep for m milliseconds.
To perform a double-deref in such cases, enclose the expression in parentheses: Sleep (%m%)
...
Numeric parameters allow and ignore the percent prefix.

Source: Scripting Language | AutoHotkey
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Since when was sleep an expression in v1???

25 Sep 2021, 23:08

iseahound wrote:
25 Sep 2021, 21:28
I don't believe it. All the code on this forum uses Sleep % expr. I was only porting from v2 to v1 that I realized it works.
there are many examples of commands in v1 that the docs say "can be an expression" for certain params. not just sleep. our converter specifically handles those parameters differently:

https://github.com/mmikeww/AHK-v2-script-converter/blob/a6aa84fa40a764246f3639b422ba6c2f8223fa01/ConvertFuncs.ahk#L58

User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Since when was sleep an expression in v1???

26 Sep 2021, 15:59

Yeah it has been like this for a while but the reason you see people use % is because it always work so there is no reason to try and remember which commands accepts expressions. I always use % myself unless I only need something that can be written using command syntax.
Please excuse my spelling I am dyslexic.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 239 guests