Reply to topic  [ 10 posts ] 
Snow Leopard AppleScript bug? 
Author Message
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
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?

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Mon Sep 07, 2009 5:03 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
What error does it give?

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Mon Sep 07, 2009 5:18 pm
Profile WWW
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
Sorry. The error is:
Quote:
Can’t make "Macintosh HD:Users:paul:Desktop:planet.jpg" into type file specification.

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Mon Sep 07, 2009 5:21 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
On my machine, it got rid of "drivename:Users:", it started with the username.

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Mon Sep 07, 2009 7:06 pm
Profile ICQ
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
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.

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Mon Sep 07, 2009 7:27 pm
Profile
Occasionally has a life
User avatar

Joined: Thu Apr 23, 2009 9:19 pm
Posts: 101
Reply with quote
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


Mon Sep 07, 2009 11:51 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
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.

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Tue Sep 08, 2009 8:43 am
Profile
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 11:36 pm
Posts: 3527
Location: Portsmouth
Reply with quote
Ah - boom boom pow! Glad to hear it's fixed. :)

_________________
Image


Tue Sep 08, 2009 11:05 am
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 6:27 pm
Posts: 12251
Reply with quote
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:

_________________
All the best,
Paul
brataccas wrote:
your posts are just combo chains of funny win

I’m on Twitter, tweeting away... My Photos Random Avatar Explanation


Tue Sep 08, 2009 11:17 am
Profile
Occasionally has a life
User avatar

Joined: Thu Apr 23, 2009 9:19 pm
Posts: 101
Reply with quote
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


Tue Sep 08, 2009 9:16 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.