No matching if

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Wolfmas

No matching if

20 Jun 2018, 11:50

Code: Select all

 Try:
PixelSearch, Px, Py, 811, 334, 811, 334, 0x414cde, 1, Fast
if ErrorLevel
  {  Var1:=(Var1+1)
	Goto, Check }
Else
   { Var2:=(Var2+1)
   Goto, Check }
return
Getting No matching if error whats wrong?
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: No matching if

20 Jun 2018, 12:00

Wolfmas wrote:

Code: Select all

 Try:
PixelSearch, Px, Py, 811, 334, 811, 334, 0x414cde, 1, Fast
if ErrorLevel
 { Var1:=(Var1+1)
 Goto, Check }
Else
 { Var2:=(Var2+1)
 Goto, Check }
return
Getting No matching if error whats wrong?
Braces Were set up wrong.

Code: Select all

Try:
	PixelSearch, Px, Py, 811, 334, 811, 334, 0x414cde, 1, Fast
	if ErrorLevel
		{
			Var1:=(Var1+1)
			Goto, Check
		}
	Else
		{
			Var2:=(Var2+1)
			Goto, Check
		}
	return
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: No matching if

20 Jun 2018, 12:04

Incorrect use of braces. Read the doc here:
https://autohotkey.com/docs/commands/Block.htm

One form of correct syntax is this:

Code: Select all

if ErrorLevel
{
  Var1:=(Var1+1)
  Goto, Check
}
Else
{
  Var2:=(Var2+1)
  Goto, Check
}
But since both paths do a Goto, Check, you could do this instead:

Code: Select all

if ErrorLevel
  Var1:=(Var1+1)
Else
  Var2:=(Var2+1)
Goto, Check
Regards, Joe
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: No matching if

20 Jun 2018, 13:18

Pleasure!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mamo691, MrDoge and 246 guests