on error, try again...

HI,

I have a script working well with :

try 
do what i want
on error
do something else
end try

I do not know how to specify that on error after doing “something else”, the script should start over from the start…
can you help me please ?

Thanks a lot in advance !!!

If you think of it as “if ˜do what i want’ did not produce an error then do not start over”, it maps easily to a repeat loop with an exit repeat after the do what I want. If do something else is a ˜no-op’, the entire [b]on error[b] section could be omitted, leaving only the surrounding try block.

repeat
	try
		doWhatIWant()
		exit repeat
	on error m
		doSomethingElse(m)
	end try
end repeat

to doWhatIWant()
	display dialog "Choose a fate:" buttons {"Success", "Failure"}
	if button returned of result is "Failure" then error "Failure!"
	"Success"
end doWhatIWant

to doSomethingElse(errMsg)
	display dialog "Error: "" & errMsg & """
end doSomethingElse

very smart ! thanks a lot !!!