• 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: Things I thought I knew, but didn't - variable scope in repeat loops
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Things I thought I knew, but didn't - variable scope in repeat loops
      • From: "Mark J. Reed" <email@hidden>
  • Prev by Date: Re: do shell sounds
  • Next by Date: Re: Things I thought I knew, but didn't - variable scope in repeat loops
  • Previous by thread: Re: Transmit Help Needed - Applescript Error : Transmit got an error : AppleEvent timed out
  • Next by thread: Re: Things I thought I knew, but didn't - variable scope in repeat loops
  • Index(es):
    • Date
    • Thread