• 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
simple “repeat with” problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

simple “repeat with” problem


  • Subject: simple “repeat with” problem
  • From: Mitchell L Model <email@hidden>
  • Date: Fri, 09 Dec 2016 16:31:38 -0500

Despite my long years of AppleScripting I despair of ever understanding the subtleties of "repeat with" loops. Here's an example that just makes no sense to me, even though I know from experience that the second formulation is often necessary. Why doesn't the first work?

This does not work:

tell application "Finder"
set theFolder to folder ("/Library/Fonts/" as POSIX file)
set theFonts to {}
repeat with theFile in the files of the theFolder  -- doesn't find any files: theFonts ends up empty
copy the name of theFile to the end of theFonts
end repeat
theFonts
end tell

whereas this does:

tell application "Finder"
set theFolder to folder ("/Library/Fonts/" as POSIX file)
set theFonts to {}
set theFiles to the files of the theFolder  -- seems silly
repeat with theFile in theFiles -- seems silly
copy the name of theFile to the end of theFonts
end repeat
theFonts
end tell



 _______________________________________________
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: simple “repeat with” problem
      • From: Christopher Stone <email@hidden>
  • Prev by Date: trivial Finder path problem
  • Next by Date: Re: trivial Finder path problem
  • Previous by thread: Re: trivial Finder path problem
  • Next by thread: Re: simple “repeat with” problem
  • Index(es):
    • Date
    • Thread