No matching if Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Wolfmas

No matching if  Topic is solved

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?
Hellbent
Posts: 150
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
JoeWinograd
Posts: 1078
Joined: 10 Feb 2014, 20:00

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

Return to “Ask For Help”

Who is online

Users browsing this forum: 8bitgunny, Forcea, Google [Bot], hanslhansl, ineuw, Mipha, swagfag, vvhitevvizard and 99 guests