• 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
Non-executed repeat loop robs variable of value/definition
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Non-executed repeat loop robs variable of value/definition


  • Subject: Non-executed repeat loop robs variable of value/definition
  • From: kai <email@hidden>
  • Date: Sun, 28 Aug 2005 16:21:56 +0100

OK - this does exactly what I'd expect:

----------

set n to 1
if false then set n to 2
n
--> 1

----------

However, I'm having some difficulty explaining the logic of this, which results in an error number number -2753 (OSAUndefinedVariable):

----------

set n to 1
if false then repeat with n from 1 to 2
end repeat
n
--> "AppleScript Error: The variable n is not defined."

----------

Similarly:

----------

set n to 1
if false then repeat with n in {2}
end repeat
n
--> "AppleScript Error: The variable n is not defined."

----------

My assumption was that the conditional statement should prevent any part of the repeat loop from being executed - but this doesn't seem to be the case. On checking whether or not the behaviour is recent, I find that it predates OS X...

Can anyone enlighten me on this one?

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Non-executed repeat loop robs variable of value/definition
      • From: deivy petrescu <email@hidden>
  • Prev by Date: Re: Time to figure out what is going on... (fixed)
  • Next by Date: Re: perl from applescript
  • Previous by thread: Re: perl from applescript
  • Next by thread: Re: Non-executed repeat loop robs variable of value/definition
  • Index(es):
    • Date
    • Thread