x404.co.uk
http://www.x404.co.uk/forum/

Snow Leopard AppleScript bug?
http://www.x404.co.uk/forum/viewtopic.php?f=4&t=2658
Page 1 of 1

Author:  paulzolo [ Mon Sep 07, 2009 5:03 pm ]
Post subject:  Snow Leopard AppleScript bug?

I have some scripts here, and upt to (and including Leopard), they work fine. In snow Leopard, they fail. This is the kind of code that is causing an error:

Code:
set this_file to "Macintosh HD:Users:paul:Desktop:planet.jpg" as file specification


Yes, the file planet.jpg is on my desktop. I’ve tried it on a Leopard Mac here, and it works. In Snow leopard, it gives an error.

Is this something anyone else knows about and has managed to overcome?

Author:  Fogmeister [ Mon Sep 07, 2009 5:18 pm ]
Post subject:  Re: Snow Leopard AppleScript bug?

What error does it give?

Author:  paulzolo [ Mon Sep 07, 2009 5:21 pm ]
Post subject:  Re: Snow Leopard AppleScript bug?

Sorry. The error is:
Quote:
Can’t make "Macintosh HD:Users:paul:Desktop:planet.jpg" into type file specification.

Author:  big_D [ Mon Sep 07, 2009 7:06 pm ]
Post subject:  Re: Snow Leopard AppleScript bug?

On my machine, it got rid of "drivename:Users:", it started with the username.

Author:  paulzolo [ Mon Sep 07, 2009 7:27 pm ]
Post subject:  Re: Snow Leopard AppleScript bug?

You get the same error with this AppleScript:

Code:
set imageFile to choose file with prompt "Choose an image file to import: "
set imageFile to imageFile as string -- turns it into a string
display dialog imageFile
set myImage to imageFile as file specification


It takes a file you have chosen, turns it into a string, and then tries to turn it back to a file reference. This way, you get a reference to a real file to work with.

Author:  KindaWobbly [ Mon Sep 07, 2009 11:51 pm ]
Post subject:  Re: Snow Leopard AppleScript bug?

Using your code in Snow Leopard gives me the same error you are getting.

Assuming there's a reason why you want it to return a file reference rather than an alias, you can get the same result in 10.6 with something like this:

Code:
set imageFile to choose file with prompt "Choose an image file to import: "
set imageFile to POSIX path of imageFile
set myImage to POSIX file imageFile

Author:  paulzolo [ Tue Sep 08, 2009 8:43 am ]
Post subject:  Re: Snow Leopard AppleScript bug?

HI,
What I am doing is fixing a Freeway Action. The Action takes a file reference from Freeway, drops it in some AppleScript and runs it. The file reference I get from Freeway is not a POSIX file - it’s a colon separated path.

Anyho, the good news is that using as alias instead of as file specification (Which I have just learned was deprecated a while back) seems to fix the problem. Thanks all.

Author:  Nick [ Tue Sep 08, 2009 11:05 am ]
Post subject:  Re: Snow Leopard AppleScript bug?

Ah - boom boom pow! Glad to hear it's fixed. :)

Author:  paulzolo [ Tue Sep 08, 2009 11:17 am ]
Post subject:  Re: Snow Leopard AppleScript bug?

Nick wrote:
Ah - boom boom pow! Glad to hear it's fixed. :)


Just need to test pn the other half’s iMac - which is PPC so is running Leopard. If it}s OK on that, I can get an update out. I’d hate to have to start writing Snow Leopard exceptions into the code.... :shock:

Author:  KindaWobbly [ Tue Sep 08, 2009 9:16 pm ]
Post subject:  Re: Snow Leopard AppleScript bug?

paulzolo wrote:
What I am doing is fixing a Freeway Action. The Action takes a file reference from Freeway, drops it in some AppleScript and runs it. The file reference I get from Freeway is not a POSIX file - it’s a colon separated path.

Anyho, the good news is that using as alias instead of as file specification (Which I have just learned was deprecated a while back) seems to fix the problem. Thanks all.

Using an alias is almost certainly the best way.

I'll confess I don't know what a Freeway Action is, and not that it matters anymore, but the code you posted was taking the, colon separated, alias reference from the original set > choose file command and turning it into a colon separated file reference. The workaround I suggested would achieve the same thing by taking the alias, colon separated path, turning into a POSIX path and then back again - this time into into a file reference rather than an alias.

Illustration of my rather garbled explanation:

Image

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/