• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Recursion Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursion Problem


  • Subject: Re: Recursion Problem
  • From: Luther Fuller <email@hidden>
  • Date: Sun, 30 Jun 2013 12:54:55 -0500

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.
Perhaps you meant to do something like this …

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.



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Recursion Problem
      • From: Michael D Mays <email@hidden>
References: 
 >Applescript to print Odd Pages only (From: Bill Guion <email@hidden>)
 >Recursion Problem (From: Michael D Mays <email@hidden>)

  • Prev by Date: Re: Recursion Problem
  • Next by Date: Re: Recursion Problem
  • Previous by thread: Re: Recursion Problem
  • Next by thread: Re: Recursion Problem
  • Index(es):
    • Date
    • Thread