Re: Things I thought I knew, but didn't - variable scope in repeat loops
Re: Things I thought I knew, but didn't - variable scope in repeat loops
- Subject: Re: Things I thought I knew, but didn't - variable scope in repeat loops
- From: Michelle Steiner <email@hidden>
- Date: Fri, 26 Dec 2008 10:43:13 -0700
On Dec 26, 2008, at 9:53 AM, Skeeve wrote:
Explain this:
set x to "hello" -- binds 'x'
log x --> "hello"
repeat with x from 1 to 3 -- rebinds 'x'
log x --> 1, 2, 3
repeat with x from 10 to 30 by 10 -- rebinds 'x'
log x --> 10, 20, 30
end repeat
end repeat
log x --> 30
Apparently, x is bound to the value at the beginning of the loop, not
at the end.
x --> "hello"
x --> 1
x--> 10
x --> 20
x --> 30
x --> 2
x--> 10
x--> 20
x--> 30
x --> 3
x--> 10
x--> 20
x--> 30
Therefore, x winds up being equal to 30.
-- Michelle
--
If you always reach your goals, you set the bar too low. If you never
reach your goals, you set the bar too high.
_______________________________________________
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