[arguable bug] confusing syntax for "if Var contains" (et al) command, shouldn't it be "IfContainsList, Var, MatchList"?

Propose new features and changes
somethingfly
Posts: 38
Joined: 23 Mar 2015, 17:23

[arguable bug] confusing syntax for "if Var contains" (et al) command, shouldn't it be "IfContainsList, Var, MatchList"?

08 Dec 2017, 15:49

Depends on how you define a bug versus a feature request (erring on the conservative side), but this command https://autohotkey.com/docs/commands/IfIn.htm is the only one I know of that has very "expression-like" syntax, and it trips up a lot of people (including myself) when trying to use it with booleans (example: https://autohotkey.com/board/topic/3759 ... mbination/).

According to help:

Code: Select all

Checks whether a variable's contents match one of the items in a list.

if Var in MatchList
if Var not in MatchList

if Var contains MatchList
if Var not contains MatchList
To follow the syntax with all the other commands, I'd assume it should be:

Code: Select all

Checks whether a variable's contents match one of the items in a list.

IfInList, Var, MatchList
IfNotInList, Var, MatchList

IfContainsList, Var, MatchList
IfNotContainsList, Var, MatchList
That way it is clear to the user it cannot be combined with booleans. Further, this change could be entirely backwards compatible, all previous usages in scripts would work, but so would the above, and the above would be what is in the documentation.

Now, I know there's this line in the documentation:

Code: Select all

The operators "between", "is", "in", and "contains" are not supported in expressions.
But the wording is confusing. If for whatever reason you don't want to update the syntax, you should at least give an example in the help to make it more clear that booleans won't work, such as

Code: Select all

The operators "between", "is", "in", and "contains" are not supported in expressions.
For example the following will not work:
if (x contains yes) and (x not contains no) ;does not work
Instead use InStr() which is supported in expressions:
if InStr(x,"yes") and !(InStr(x,"no")) ;does work

Return to “Wish List”

Who is online

Users browsing this forum: gongnl and 17 guests