Some Questions

Hi
I have two questions to ask.

1.How to break from a “repeat”.In my app,I want to break from “repeat” when some “if” is successful.
2.I want to wait an image disappear.I just know “waitfor,10,imagename” and I still want to know the contrary.
3.I want script like this:

Find a image in every 5 seconds,If it is found,a log will be recorded. If not,keep finding.If 10 logs have reported. End loop.

Here are some answers to your questions:

1.How to break from a “repeat”.In my app,I want to break from “repeat” when some “if” is successful.

The command you want for this is “exit repeat”.

2.I want to wait an image disappear.I just know “waitfor,10,imagename” and I still want to know the contrary.

Basically, you’ll need to write a little loop and use the imageFound() function. It might look something like this:

put the time into startTime
repeat while imageFound(0,imagename)
    if the time - startTime > 10 then
        throw "ImageStillFound", "Image " & imagename & " remained for 10 seconds"
    end if
    wait 0.25
end repeat

You may want to adjust this somewhat for your needs. Turning it into a generic script that accepts imagename and the maximum time as parameters would be an obvious enhancement.

3.I want script like this: Find a image in every 5 seconds,If it is found,a log will be recorded. If not,keep finding.If 10 logs have reported. End loop.

Something like this, perhaps?

set foundCount to zero
repeat
    if imageFound(imagename) then
        log "image " & imagename & " was found"
        add 1 to foundCount
        if foundCount is 10 then
            exit repeat
        end if
    end if
    wait 5 seconds
end repeat