Re: path to question?
Re: path to question?
- Subject: Re: path to question?
- From: Ric Phillips <email@hidden>
- Date: Tue, 17 Jul 2001 11:04:17 +1000
On 17/7/01 7:55 AM, "Admin nimlok.com" <email@hidden> wrote:
>
Thanks Steve for your reply.
>
>
Actually what I'm trying to do is get the path to the folder
>
that an application is in?
>
>
set filepath to path to creator "CDP3" as string
>
>
returns
>
>
file "HD I:Desktop Folder:VectorWorks:VectorWorks"
>
>
I want
>
>
file"HD I:Desktop Folder:VectorWorks:"
>
>
I've tried delimiting the string but get errors.
>
applescript acts like filepath is not a string,
>
not sure why?
>
>
any help would greatly be appreciated.
>
thanks
>
Dave
>
>
Don't know why your's doesn't work. The following code code will return the
path string you want for a designated creator code. In this sample I've used
the Acrobat type.
Short version is,
----------------------------
tell application "Finder"
set fRef to the container of the (path to creator "CARO") as string
end tell
----------------------------
Result (On my machine)
==> "machd:Applications (Mac OS 9):Acrobat Reader 4.0:"
I would however use a variable and a try wrapper like so...
--------------------------------
set crCode to "CARO" -- Acrobat Reader
tell application "Finder"
try
set fRef to the container of the (path to creator crCode) as string
on error errmsg number errnum
if errnum = -35 then
-- Catch and pass or flag the error raised
-- when an app with the designated creator
-- code does not exist
end if
end try
end tell
--------------------------------
Result ==> "machd:Applications (Mac OS 9):Acrobat Reader 4.0:"
Also of interest is the case where two versions of the same app exist with
the same creator code. I have Office 2001 and 98 installed for example, and
both Word 8 and 9 have 'MSWD' as their creator codes. You can check a
version with,
--------------------------------
tell application "Finder"
set fileRef to the path to creator "MSWD"
set versionRef to the version of fileRef
end tell
---------------------------------
Result (On my machine)
==> "9.0 (2510), ) 1983-2000 Microsoft Corporation"
Which means it is picking up the 2001 Word (version 9). As to why it gets
that one (at the finder object model level) I couldn't say. And how you get
the finder to pick up a reference to every app with a given creator code is
something I haven't looked at - but it definitely is a condition that a
programmer may need to watch out for when using this technique for locating
apps. What I find interesting is that 'path to creator x' is an acceptable
reference that returns a result, but 'creator x' or 'name of creator x' are
not and return errors - which to my mind is a rather counter-intuitive
behaviour on the part of either Apple Script itself or the implementation of
the Finder classes. Another day when I have the time.....
Regards,
Ric Phillips
Computer Laboratory Support Officer
Faculty of Humanities and Social Sciences
La Trobe University
9479 2792