(please forgive if this should be obvious or is a faq, I have searched the archives & failed, and I have RTFM’d till I’m blue in the face)
How do you turn
item of { a list of objects}
into the actual object?
I have:
tell application “Finder”
repeat with foo in selection as list
return foo
end repeat
end tell
this returns:
item 1 of {folder “dorfman” of folder “Users” of startup disk of application “Finder”, folder “emergency” of folder “Users” of startup disk of application “Finder”, folder “Shared” of folder “Users” of startup disk of application “Finder”}
I just want it to return this:
folder “dorfman” of folder “Users” of startup disk of application “Finder”
When you have a real list or a collection that you don’t need to coerce into a list, this doesn’t happen, “item 1” of it is just the item itself, not “item 1 in {the list of things}”
But with the case of a finder selection, I have to coerce “selection” into a list, or I can’t iterate over it at all - it is a “property” and not a list. I don’t understand this:
tell application “Finder” to return selection
returns
{folder “dorfman” of folder “Users” of startup disk of application “Finder”, folder “emergency” of folder “Users” of startup disk of application “Finder”, folder “Shared” of folder “Users” of startup disk of application “Finder”}
It looks just like a list to me, but
tell application “Finder” to return 1st item of selection
errors with:
Finder got an error: Can’t get item 1 of selection.