Image found error seen as a command

So trying to make this code work but I’m getting an error where I understand the idea of what the issue is but not what I need to do to fix it.

The code goes like this

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
To handle SelectOptionBox
Set SearchRectangle to my Pane2

set MyTextLocation to ImageRectangle (text:(CheckBox_Name))

put (left of MyTextLocation – 35, top of MyTextLocation - 3, left of MyTextLocation, bottom of TextLocation + 2) into MySearchRect

put "MySearchRect: " && MySearchRect

If ImageFound(ImageName:”Locators/CheckBox/Box_UNCHECKED”, searchRectangle: MySearchRect)

 Then 

     Click FoundImageLocation() 

  Return 

Else

 ImageFound(ImageName:”Locators/CheckBox/Box_CHECKED”, searchRectangle: MySearchRect)

 Return 

End if

End SelectOptionBox
//////////////////////////////////////////////////////////////////////////////////////////////////////////

So the error I get is (ERROR: “imagefound” was called as a Command, but is only Available as a Functon)

But I’m not trying to use it as a command … just trying to use Imagefound. So what’s making it think I’m trying to use imagefound as a command?

Hi Metazoxan,
ImageFound() is a function, not a procedure. So You need to do something with the return value, what is a boolean here. Either You write

set thisImgFnd to ImageFound(…)

or You simply put both lines of Your else-branch together, means

return ImageFound(…)

BR