Clash with Foundation & display dialog?

asobjc

(Phil Stokes) #1

Kind of following on from this discussion, I guess, I appear to have some kind of namespace clash that I can’t resolve (my effort to put various terms in pipes, and to use ‘using terms from’ have not met with success).

This script works fine:

use scripting additions
# use framework "Foundation"

set _hd to path to startup disk as text
set anIcon to _hd & "System:Library:CoreServices:Finder.app:Contents:Resources:Finder.icns"
display dialog "hello finder" with icon file anIcon

However, uncomment the use framework "Foundation" line and I get an error:

Error: File does not contain an icon.

That’s unfortunate because I’d like to both get the icon into Display Dialog and use Foundation later in my script.

Any suggestions for a workaround?


(Phil Stokes) #2

Ah, answering myself: Wrap it in a tell Finder block.

Still, wonder why adding the Foundation framework causes the clash?


(Shane Stanley) #3

You see the same thing here:

read file "Macintosh HD:Users:shane:Desktop:Dictionary.html"

The problem is to do with the use of the file specifier. I don’t know why it happens, but the workaround I use is this:

display dialog "hello finder" with icon anIcon as «class furl»

(Phil Stokes) #4

Thanks. I guessed it was file but I couldn’t get away with wrapping it in pipes. Didn’t know about the class furl trick. :+1:t3:


(Shane Stanley) #5

You can also avoid it altogether:

set iconAlias to path to resource "Finder.icns" in bundle (application "Finder")


(Phil Stokes) #6

Oh, that’s much nicer. I like that. Thanks a lot.