If and or statements Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Vh_
Posts: 200
Joined: 17 Mar 2017, 22:06

If and or statements

02 Apr 2019, 13:36

Hi, can someone please review this and tell me why I am not getting "I'm an error" regardless of if I have a matching OR (ABC or XYZ)?

Thanks,
Vh_

Code: Select all

Number = 123
Identifier = 123
Code = CAB ;result should be  "not an error"?


if (SSN = Account) && (Code != "ABC" or Code != "XYZ")
	Msgbox, i'm an error
else
	msgbox, not an error.
Last edited by Vh_ on 02 Apr 2019, 13:49, edited 1 time in total.
User avatar
sinkfaze
Posts: 609
Joined: 01 Oct 2013, 08:01

Re: If and or statements

02 Apr 2019, 13:48

I copied and ran your code as is, I got i'm an error.
Vh_
Posts: 200
Joined: 17 Mar 2017, 22:06

Re: If and or statements

02 Apr 2019, 13:50

sinkfaze wrote:
02 Apr 2019, 13:48
I copied and ran your code as is, I got i'm an error.
I misquoted myself! Edited original post. It should be opposite the result you got.
Vh_
Posts: 200
Joined: 17 Mar 2017, 22:06

Re: If and or statements  Topic is solved

02 Apr 2019, 13:54

phaleth on #ahk IRC helped me figure this out! Thanks!

Code: Select all

Number = 123
Identifier = 123
Code = ABC ;result should be  "not an error"?


if (SSN = Account) && (Code != "ABC" && Code != "XYZ")
	Msgbox, i'm an error
else
	msgbox, not an error.
User avatar
sinkfaze
Posts: 609
Joined: 01 Oct 2013, 08:01

Re: If and or statements

02 Apr 2019, 13:57

Well that's much easier to solve.

(Code != "ABC" or Code != "XYZ")

There is literally no value for Code which will cause this statement to evaluate as true. Perhaps you meant to evaluate with and?

(Code != "ABC" and Code != "XYZ")

Return to “Ask For Help”

Who is online

Users browsing this forum: clevek, Gonzalo94 and 84 guests