Clash with Foundation & display dialog?

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 & ""
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?

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

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

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»
1 Like

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:

You can also avoid it altogether:

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

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