MACSCRPT Archives

May 2003

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Paul Berkowitz <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Mon, 26 May 2003 18:08:47 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (53 lines)
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

ATOM RSS1 RSS2