Small Error in EnvSub Documentation

Share your ideas as to how the documentation can be improved.
Sparkon
Posts: 11
Joined: 04 Oct 2016, 15:55

Small Error in EnvSub Documentation

Post by Sparkon » 22 Jun 2020, 13:23

The documentation for EnvSub at https://www.autohotkey.com/docs/commands/EnvSub.htm currently states the following for the parameter named Value:
Any integer, floating point number, or expression (expressions are not supported when TimeUnits is present).
However, that parenthetical which I have boldfaced above seems to be incorrect/outdated, and expressions are supported by for the parameter named Value, based on the following evidence:
  • Example #2 on that same documentation page uses an expression for Value even though TimeUnits is present.
  • The documentation for the similar EnvAdd at https://www.autohotkey.com/docs/commands/EnvAdd.htm does not mention any such limitation for its parameter named Value.
  • I was writing some code using EnvSub, and my code seems to be working fine even when I use an expression for the parameter named Value with TimeUnits present.
  • Actually, I found expressions were working for Value even without percent-escaping (to force expression mode) and TimeUnits present.
Last edited by gregster on 22 Jun 2020, 13:27, edited 1 time in total.
Reason: Moved to "Suggestions on documentation improvements"
swagfag
Posts: 4135
Joined: 11 Jan 2017, 17:59

Re: Small Error in EnvSub Documentation

Post by swagfag » 23 Jun 2020, 19:05

it appears expressions are indeed supported(unless the excerpt is meant to refer to some other kind of usage)

Code: Select all

var1 := 20050126
var2 := 20040125
EnvSub, var1, % var2 + 1, days
MsgBox, %var1%  ; The answer will be 366 since 2004 is a leap year.

var1 := 20050126
var2 := 20040125
var1 -= var2 + 1, days
MsgBox, %var1%  ; The answer will be 366 since 2004 is a leap year.
User avatar
Ragnar
Posts: 367
Joined: 30 Sep 2013, 15:25

Re: Small Error in EnvSub Documentation

Post by Ragnar » 16 Jul 2020, 08:19

Fixed via PR #439.
Post Reply

Return to “Suggestions on documentation improvements”