Sender: |
|
Mime-version: |
1.0 |
Date: |
Mon, 26 May 2003 18:08:47 -0700 |
Reply-To: |
|
Content-type: |
text/plain; charset="US-ASCII" |
Subject: |
|
From: |
|
In-Reply-To: |
|
Content-transfer-encoding: |
7bit |
Parts/Attachments: |
|
|
On 5/26/03 5:35 PM, "Chip Griffin" <[log in to unmask]> wrote:
> Why does this script:
>
> -- Begin Script
> set theItem to {alias "Macintosh HD:Users:chip:Pictures:dog_cats.jpg"}
> tell application "Finder"
> set comment of item theItem to "Test Test"
> end tell
> -- End Script
>
> Yield this error:
> "Finder got this error: A descriptor type mismatch occurred."
>
> I receive the same error if I tried to set a variable to the "comment
> of item theItem".
You've managed to make the most convoluted expression out of the simplest
things.
For a start. { } braces in AppleScript define a list or a record. they can't
be used like parentheses just to mean "I want to keep the stuff here
together." So:
{alias "Macintosh HD:Users:chip:Pictures:dog_cats.jpg"}
is a list containing one item, an alias. What do you need a list for?
Naturally the Finder is upset: it can't set comments of AppleScript lists,
only of Finder items (files, folders, disks). But it objects before it even
tries to set a comment: simply the expression
item {someList}
is all wrong. An AppleScript list can't be a Finder item.
In addition, the Finder will coerce your alias to a file or folder without
the extra 'item' (though that will coerce too). So:
set theItem to alias "Macintosh HD:Users:chip:Pictures:dog_cats.jpg"
tell application "Finder" to set comment of theItem to "Test Test"
(To avoid all coercions, you would do:
set filePath to "Macintosh HD:Users:chip:Pictures:dog_cats.jpg"
tell application "Finder" to set comment of item filePath to "Test Test"
)
--
Paul Berkowitz
|
|
|