repeat condition


I want to 2 condition for repeat:
1. num < 4
2. until imagefound

so I write as this:

Set num to 0
repeat until imagefound("img1") and num <4
typetext downArrow
set num to num +1
end repeat
Is this right?
but it seems can not exit repeat loop. How can I add two condition for repeat.

Thanks for your help.


  • JonathanOSXJonathanOSX ForumAdmin admin
    The problem here is that you either want to switch to repeat while or you want to use or num > 4. The way you have it structured it won't exit until both the image is found and num is less than 4 so if it doesn't find it in the first 4 tests it will just loop forever whether it finds the image or not (while the num variable keeps incrementing).

    As an additional hint SenseTalk automatically provides an index count (starting at 1) for any repeat loop. So I would recommend restructuring your loop like this:
    repeat until imageFound("Img1") or repeatIndex() > 5
        TypeText downArrow
    end repeat
  • I see my problem now. Thanks a lot!
Sign In or Register to comment.