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: has <email@hidden>
- Date: Fri, 26 Dec 2008 21:42:16 +0000
Skeeve wrote:
If loop variables were scoped only to the repeat block, the final
'log' command would give 'hello', not 3.
HTH
Partly. 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
Same thing. 'x' is bound to "hello", then rebound to 1, then to 10,
20, 30, then 2, then 10, 20, 30, then 3, then 10, 20, 30. Exactly what
you'd expect based on the documentation.
HTH
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
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