If Var In/Contains

Discuss the future of the AutoHotkey language
djvj11
Posts: 15
Joined: 21 Jun 2014, 01:30

If Var In/Contains

19 Dec 2015, 23:49

What's the equivalent that I should use for these conditionals?

If X In abc,def,fyg
{
...
}

When I try to use this I get a msg saying reserved for future use. Has this not been re-implemented yet or just removed?
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: If Var In/Contains

20 Dec 2015, 02:15

If var between/is/in/contains has been removed, as listed in v2-changes.

Keywords contains and in are reserved for future use in expressions, as the message tells you. That's pretty clearly saying they were not simply removed permanently. They will not have the same syntax, because they are expression operators, not special IF-statements; IF always takes an expression in v2. In fact, what you are getting a message about is an expression operator which never existed and therefore couldn't have been removed. x := y in z will give you the same message.

The alternatives are the same as in v1: InStr, RegExMatch, Loop Parse, indexing into an associative array... whatever other solution you can imagine.
djvj11
Posts: 15
Joined: 21 Jun 2014, 01:30

Re: If Var In/Contains

20 Dec 2015, 02:21

Ok thanks Lexikos. So I have to wait till the replacement is in or use one of the existing methods.

Off the top of your head, do you know which would be fastest? I figured the array or "If (x=1 || x=2 || x=3 || etc)"
djvj11
Posts: 15
Joined: 21 Jun 2014, 01:30

Re: If Var In/Contains

20 Dec 2015, 06:10

So far I've found regexmatch to be fastest w/o false positives. I tried all possibilities I could think of. Loop Parse was slowest.

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 54 guests