• 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: Error opening file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error opening file


  • Subject: Re: Error opening file
  • From: Christopher Nebel <email@hidden>
  • Date: Mon, 13 May 2002 15:55:52 -0700

On Monday, May 13, 2002, at 12:22 PM, Christopher Coulon wrote:

set macroName to "*rodentHeart.obj.2.04a"
set macroPath to "/GAIA/*Test Macros"
tell application "Finder"
select item macroName of macroPath
open selection
end tell

Execution Error
Can't make "*rodentHeart.obj.2.04a" into a integer.

The macroName and macroPath refer to valid names and paths, so why the error?

AppleScript is a bit more object-oriented than you are apparently used to. Lots of things have items, so AppleScript looks at the class of the thing on the right-hand side of the "of" to figure out what it's supposed to do. In this case, it's trying to get an item of the string "/GAIA/*Test Macros"; strings have numbered items (the characters), but not named ones, hence the error.

Change the "select" line to say "item macroName of folder macroPath", and you'll be a lot closer. However, you should also be aware that...

1. The Finder doesn't understand POSIX paths directly. If you make the change exactly as I suggested, it will try to find a folder named "/GAIA/*Test Macros" on the desktop. (The Finder assumes things are from the desktop unless you say otherwise.) If that name is supposed to be a POSIX path, you'll need to do something more like 'item macroName of folder "*Test Macros" of folder "GAIA" of the startup disk'.

2. There's no need to select an item first and then operate on it, unless you want to see the selection change for some reason. Saying "open item..." will work just as well. Better, in some respects.

If you haven't already, you should check out the AppleScript Language Guide, and possibly some of the sample scripts on the AppleScript web site (http://www.apple.com/applescript). There's a bunch of stuff on basic Finder scripting.


--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Error opening file (From: Christopher Coulon <email@hidden>)

  • Prev by Date: Re: 'Concatenate' from a list
  • Next by Date: Problem with getting int'l characters
  • Previous by thread: Re: Error opening file
  • Next by thread: Re: Error opening file
  • Index(es):
    • Date
    • Thread