Re: Setting labels of Finder items in Panther? You can, but...
Re: Setting labels of Finder items in Panther? You can, but...
- Subject: Re: Setting labels of Finder items in Panther? You can, but...
- From: Nigel Garvey <email@hidden>
- Date: Wed, 29 Oct 2003 14:47:55 +0000
Charles Arthur wrote on Tue, 28 Oct 2003 16:14:27 +0000:
>
In OS9, the following worked once you'd chosen a file:
>
>
tell application "Finder" to set label index of selection to 2
>
>
--which would set the label to red, the usual default for label index 2.
>
>
In Panther however it yields
>
"Finder got an error: Can't set label index of selection to 2."
>
>
But this script
>
>
tell application "Finder"
>
set theselection to selection
>
set label index of item 1 of theselection to 2
>
end tell
>
>
--works fine
>
--because theselection comes up as a list,eg {document file
>
"definitions-flapper" of folder "Desktop" of folder "charles" of folder
>
"Users" of startup disk}. (But then surely it was a list in OS9 too?)
>
So I've got a workaround, but it would be nice to understand why one
>
version works and the other doesn't.
It's to do with the different ways the two Finders handle some reference
expressions. The result of *getting* the selection - or of setting a
variable to it - is, as you say, a list in both cases. And both Finders
can (apparently) set the label index of a file or of a list of files.
But in the expression 'label index of selection', 'selection' is a
reference to a property of the Finder, not a list as such. Before OS X,
'selection' would work as part of a longer Finder reference. In X, it
doesn't. You have to 'get' the selection first and then use the result.
This is annoying, but not uncommon in application scripting.
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.