How to exit a while loop?

Could anyone please tell me how to exit a while loop or a repeat loop?

MCSVZW,

You can use “exit repeat” or “end repeat”.

You could use “exit repeat” in a situation such as this:

repeat with each item of EveryImageLocation ("CloseButton_Focus") 
	click it 
	if ImageFound ("SaveFile") then 
		log "something came up"
		exit repeat
	end if
end repeat 

In this context, eggPlant will look for every instance of the close window button, and close windows until all of the windows are gone, and then end the repeat and go on with the script. The exit repeat comes in if one of the windows it tries to close is, for example, an unsaved text document and a panel appears prompting the user to choose whether or not to save the document. If this happens, it will exit the repeat loop and continue on with the rest of the script.

Neither of these options (end repeat or exit repeat) causes the script to fail.
If you want to fail the script when this happens, you will need to have it log an error or throw an exception.

logerror "something interrupted the script!"
//or
throw "something interrupted the script!"

-Elizabeth

Thanks Elizabeth