how to identify conditions

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MonuKashyap
Posts: 112
Joined: 06 Jun 2016, 21:32

how to identify conditions

28 May 2018, 04:58

How to identify that which condition gone true?

suppose,

a=apple
b=2

If (a="apple" || b="boll")
Msgbox True


in this How to identify by script that which condition gone true to reach the msgbox, by user?
1. by apple (first condition)
2. by boll (second condition)
Last edited by MonuKashyap on 29 May 2018, 07:19, edited 1 time in total.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: how to identify conditions

28 May 2018, 05:53

MonuKashyap wrote:How to identify the condition gone true?

suppose,

a=apple
b=2

If (a="apple" || b="boll")
Msgbox True


in this How to identify by script that which condition gone true to reach the msgbox, by user?
1. by apple (first condition)
2. by boll (second condition)
Play with this, I think it can help you

Code: Select all

a = apple
b = 2

if (a = "apple" and b = "2")
	msgbox, it's true
else
	msgbox, % "It's not true because a = " a " and b = " b
ExitApp
imustbeamoron
Posts: 44
Joined: 18 Aug 2016, 22:56

Re: how to identify conditions

28 May 2018, 05:55

i would say, if you need to know which argument caused the ''true' condition, you need to restructure your code and use individual "if" statements.
MonuKashyap
Posts: 112
Joined: 06 Jun 2016, 21:32

Re: how to identify conditions

29 May 2018, 01:39

imustbeamoron wrote:i would say, if you need to know which argument caused the ''true' condition, you need to restructure your code and use individual "if" statements.
How do i do that?
where both conditions are variable
MonuKashyap
Posts: 112
Joined: 06 Jun 2016, 21:32

Re: how to identify conditions

29 May 2018, 03:16

AHKStudent wrote:
MonuKashyap wrote:How to identify the condition gone true?

suppose,

a=apple
b=2

If (a="apple" || b="boll")
Msgbox True


in this How to identify by script that which condition gone true to reach the msgbox, by user?
1. by apple (first condition)
2. by boll (second condition)
Play with this, I think it can help you

Code: Select all

a = apple
b = 2

if (a = "apple" and b = "2")
	msgbox, it's true
else
	msgbox, % "It's not true because a = " a " and b = " b
ExitApp

No my dear friend, I want to know which condition causes to get in to the program for user, condition apple or condition ball. How do i identify that?
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: how to identify conditions

29 May 2018, 03:19

MonuKashyap wrote:
AHKStudent wrote:
MonuKashyap wrote:How to identify the condition gone true?

suppose,

a=apple
b=2

If (a="apple" || b="boll")
Msgbox True


in this How to identify by script that which condition gone true to reach the msgbox, by user?
1. by apple (first condition)
2. by boll (second condition)
Play with this, I think it can help you

Code: Select all

a = apple
b = 2

if (a = "apple" and b = "2")
	msgbox, it's true
else
	msgbox, % "It's not true because a = " a " and b = " b
ExitApp

No my dear friend, I want to know which condition causes to get in to the program for user, condition apple or condition ball. How do i identify that?
here is a noob way of doing it

Code: Select all

a = apple
b = 2

if (a != "apple")
	achanged := 2
if (b != "2")
	bchanged := 2
if (achanged = "2" and bchanged = "2")
	msgbox, Both changed
if (achanged = "2" and bchanged = "")
	msgbox, % "a is no longer apple, it's now " a
if (bchanged = "2" and achanged = "" )
	msgbox, % "b is no longer 2, it's now " b
if (a = "apple" and b = "2")
	msgbox, Nothing changed
ExitApp

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: how to identify conditions

29 May 2018, 04:07

Code: Select all

compare(a, b) {
	if (a = "apple")
		MsgBox, % "a determined the result"
	else if (b = 2)
		MsgBox, % "b determined the result"
	else
		MsgBox, % "neither is true"
}

a := "apple", b := 2, compare(a, b)
a := "orange", b := 2, compare(a, b)
a := "kiwi", b := 100, compare(a, b)
MonuKashyap
Posts: 112
Joined: 06 Jun 2016, 21:32

Re: how to identify conditions

29 May 2018, 07:09

Well i am something looking like that :-

a=pwd1
b=pwd2
inputbox, InputByUser
if (InputByUser=pwd1 || InputByUser=pwd2)
; if the condition goes true, by condition1 i.e. entering pwd1 then,
msgbox The user get loged in by by condition1
; and if the condition goes true, by condition2 i.e. entering pwd2 then
msgbox The user get logged in by condition2

The problem is that the pwd1 and pwd2 are variable, can be changed any time
any suggestion ??

and i know the single if condition can do it, but it is more simple and easy if the "If with Or" condition could do that.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: how to identify conditions

29 May 2018, 07:19

thats what the function does already, just extract its body and change the variable names accordingly
MonuKashyap
Posts: 112
Joined: 06 Jun 2016, 21:32

Re: how to identify conditions

16 Jun 2018, 03:03

swagfag wrote:thats what the function does already, just extract its body and change the variable names accordingly
Can you please explain How??

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], peter_ahk, submeg and 89 guests