Using "contains" inside parenthesis?

Get help with using AutoHotkey and its commands and hotkeys
chinagreenelvis
Posts: 19
Joined: 19 Oct 2015, 16:21

Using "contains" inside parenthesis?

17 Jul 2017, 01:33

I generally format my code:

Code: [Select all] [Download] GeSHi © Codebox Plus

If (condition1) || (condition2 && condition3)
{
do stuff
}


But this doesn't work when using contains. For example:

Code: [Select all] [Download] GeSHi © Codebox Plus

If (condition1) || (condition2 && Var contains Var2, Var3)
{
don't bother to do stuff because you'll get an illegal character error, apparently AHK thinks the second parenthesis is part of the variable
}


How do I get this to function while still using brackets, which are essential for and/or operations?
User avatar
Exaskryz
Posts: 2610
Joined: 17 Oct 2015, 20:28

Re: Using "contains" inside parenthesis?

17 Jul 2017, 01:50

Per contains documentation:

The operators "between", "is", "in", and "contains" are not supported in expressions.


You can stack the If statements. Perhaps in this instance, it'll be easier for a gosub routine:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

BoBo
Posts: 1427
Joined: 13 May 2014, 17:15

Re: Using "contains" inside parenthesis?

17 Jul 2017, 01:54

If (condition1) || (condition2 && (InStr(Var,Var2) || InStr(Var, Var3))) Probably nonsense

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 37 guests