Perry_M
Perry_M

Reputation: 137

autohotkey if var is with OR

I know this is stupid simple, but it doesn't work.

Somehow I would like to shorten this variable using an operand but whatever . Can someone please show me a shorthand way writing this code?

var := "abc"
if (var = "abc" or var = "def" or var = "ghi")
{
    MsgBox Yes
}
else
    msgbox No
Return

IE: if var = ABC|DEF|GHI

also can I shorten the code to one line?

Upvotes: 0

Views: 163

Answers (1)

Jim U
Jim U

Reputation: 3366

This is functionally equivalent to your code in one line:

msgbox % var ~= "^(abc|def|ghi)$" ? "Yes" : "No"

Upvotes: 1

Related Questions