IF with some kind of crazy exit scheme?

This works for me:

repeat 20 times

if imageFound("RedWebDelete") then
	DoubleClick foundImagelocation()
	Click "ConfirmWebDelete"
	
end if

end repeat

However, sometimes only 2 or 3 of the “RedWebDelete” images mentioned above are present. My script then goes through 18 unnecessary IFs… anyway to tell it that if there are NO MORE “RedWebDelete” images to end the IF?

See what I mean? Thanks!

else exit repeat

:slight_smile:

sweet.

Like this? Gave me a syntax error

repeat

if imageFound("RedWebDelete") then
	DoubleClick foundImagelocation()
	Click "ConfirmWebDelete"
	
end if

else exit repeat

The way to use “exit repeat” here would be like this:

repeat 20 times 

  if imageFound("RedWebDelete") then 
    DoubleClick foundImagelocation() 
    Click "ConfirmWebDelete" 
  else
    exit repeat
  end if 

end repeat 

Another possible solution is to use “repeat while”:

repeat while imageFound("RedWebDelete") 
    DoubleClick foundImagelocation() 
    Click "ConfirmWebDelete" 
end repeat 

This is a bit simpler and has the added advantage that it can handle any number of instances of the image.