• 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
When is a list not a list?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

When is a list not a list?


  • Subject: When is a list not a list?
  • From: Ric Phillips <email@hidden>
  • Date: Fri, 16 Feb 2001 16:00:32 +1100

I have been apple scripting for a few years now, but I must confess, while
quite confident with my general programming ability, the way AS behaves
leaves me feeling at times that I will never get a clear understanding of
how it handles data / objects. For example:

tell application "Finder"
set root to (choose folder)
the name of every folder in root
end tell

Returns a list of folder names to the result - which is well and good. But;

tell application "Finder"
set root to (choose folder)
repeat with thisFolder in (the name of every folder in root)
display dialog thisFolder
end repeat
end tell

does not bring up a sequence of dialog boxes with the names of each sub
folder, whereas;

tell application "Finder"
set root to (choose folder)
repeat with thisFolder in (the name of every folder in root as list)
display dialog thisFolder
end repeat
end tell

does in fact bring up the expected sequence of dialog boxes.

Now AS is not my first programming language by any stretch, but this sort of
odd behaviour (from my point of view anyway) makes it hard to get a clear
picture of the its way data structures and objects work.

Could someone be kind enough to explain to me why the clause

the name of every folder in <alias to folder>

which seems to return a list structure, needs to be cast explicitly to a
list type when used in the statement,

repeat with thisFolder in (the name of every folder in <alias to folder>)

PS> I have worked out that 'as list' is necessary anyway, to cover cases
where the clause will only return one reference. I tested the above
variations on folders with more than one sub folder.

TIA

Ric Phillips

Computer Laboratory Support Officer
Faculty of Humanities and Social Sciences
La Trobe University
9479 2792


  • Follow-Ups:
    • Re: When is a list not a list?
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Re: WHEN WILL THE LIST SERVER BE FIXED?
  • Next by Date: Re: When is a list not a list?
  • Previous by thread: Reference finder windows to specific screen?
  • Next by thread: Re: When is a list not a list?
  • Index(es):
    • Date
    • Thread