On Jun 30, 2013, at 12:33 PM, Michael D Mays wrote:
I would expect that when I run the script below that do_that would recursively call itself until a true was returned and then "I escaped" would be displayed. What repeatedly happens is two false's are returned and then the "I escaped" dialog is displayed even though true has not been return.
First, your script is not recursive. Neither of the handlers call themselves nor do both call the other.
on run
my do_this()
end run
on do_this()
repeat
do_that()
if the result then exit repeat
end repeat
display dialog "I escaped"
end do_this
on do_that()
set a_list to {false, false, false, false, false, false, false, false, false, true}
set a_random_number to (random number from 1 to 10)
display dialog (a_random_number as string) & " " & item a_random_number of a_list
return item a_random_number of a_list
end do_that
This seems to do what you described.