Re: Non-executed repeat loop robs variable of value/definition
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