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

Re: Non-executed repeat loop robs variable of value/definition


  • Subject: Re: Non-executed repeat loop robs variable of value/definition
  • From: deivy petrescu <email@hidden>
  • Date: Sun, 28 Aug 2005 11:54:55 -0400


On Aug 28, 2005, at 11:21, kai wrote:

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

kai, I have the same results. But something worse happens here.

<script>
set n to 1
if n ≠ 1 then
    log n
    log "this"
    set k to true
else
    log n  -- 1
    log "that" -- "that"
    repeat with n from 1 to 10
    end repeat
end if
n
-->10
</script>

which is opposite of what I would expect following your examples.
Now for the nightmare:
<script>
set n to 1
if n = 1 then
    log n   -- 1
    log "this" -- "this"
    set k to true
else
    log n
    log "that"
    repeat with n from 1 to 10
    end repeat
end if
n
--> "AppleScript Error: The variable n is not defined."
</script>

By the way, thanks for spoiling my weekend!!!

:)

deivy
_______________________________________________
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: kai <email@hidden>
References: 
 >Non-executed repeat loop robs variable of value/definition (From: kai <email@hidden>)

  • Prev by Date: Re: Time to figure out what is going on... (fixed)
  • Next by Date: A Yummy (_Not_) Bug: Gremlin is Rewriting my GUI-Scripting
  • Previous by thread: Non-executed repeat loop robs variable of value/definition
  • Next by thread: Re: Non-executed repeat loop robs variable of value/definition
  • Index(es):
    • Date
    • Thread