• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bug? was Re: add finder item to iTunes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug? was Re: add finder item to iTunes


  • Subject: Re: Bug? was Re: add finder item to iTunes
  • From: has <email@hidden>
  • Date: Tue, 19 Aug 2008 21:17:59 +0100

Joe wrote:

Michelle, if I  write:

tell application "iTunes"
open alias "Mac HD:Users:joe:Desktop:04 MySong.mp3"
end tell

the script errors and returns this error message:

iTunes got an error: Can't get alias "Mac HD:Users:joe:Desktop:04 MySong.mp3" of <<script>>.


It's an AppleScript screw-up. The problem is that 'alias' literals that appear as command parameters are being packed into Apple events as object specifiers ('references' in AppleScript parlance) instead of typeAlias descriptors as you'd expect. e.g.:

	set theAlias to (alias "MacHD:users:foo:todo.txt")
	tell application "TextEdit"
		open theAlias
	end tell

	--> app(u'TextEdit').open(mactypes.Alias(u'/Users/has/todo.txt'))

and:

	tell application "TextEdit"
		set theAlias to (alias "d1:users:has:todo.txt")
		open theAlias
	end tell

	--> app(u'TextEdit').open(mactypes.Alias(u'/Users/has/todo.txt'))

work as intended, but:

tell application "TextEdit"
open (alias "d1:users:has:todo.txt")
end tell

--> app (u'TextEdit ').AS_newreference (app.elements('alis').byname(u'd1:Users:has:todo.txt')).open()


doesn't. (Note: I'm using ASTranslate to sniff the outgoing Apple events as it's easier to read, but you can go enable AEDebug yourself if you prefer to see 'em raw. That 'app.elements(...).byname(...)' bit is what a raw object specifier looks like in Python.)

I suspect this problem may be new in Leopard, caused by changes to the way that 'alias' literals are treated at compile-time. Note that AppleScript's 'date' literals - another special-case - are still being appropriately packed into Apple events as DateTime values, e.g.:

tell application "Finder"
set (modification date of folder "test" of home) to (date "Saturday, December 1, 2007 12:00:00 AM")
end tell


--> app (u'Finder ').home.folders[u'test'].modification_date.set(datetime.datetime(2007, 12, 1, 0, 0))

as are 'POSIX file' literals:

	tell application "Finder"
		open POSIX file "/Users/foo"
	end tell

	--> app(u'Finder').open(mactypes.File(u'/Users/has'))

so it does just seem to be 'alias' literals that are affected.

If you or anyone else is bothered by this new behaviour and the problems it causes for various applications, I recommend you go file a bug report on it:

	http://bugreport.apple.com

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Bug? was Re: add finder item to iTunes
      • From: Luther Fuller <email@hidden>
  • Prev by Date: Re: excel
  • Next by Date: Re: Bug? was Re: add finder item to iTunes
  • Previous by thread: Re: iCal Calendar Help
  • Next by thread: Re: Bug? was Re: add finder item to iTunes
  • Index(es):
    • Date
    • Thread