Re: Path to app ...
Re: Path to app ...
- Subject: Re: Path to app ...
- From: Christopher Nebel <email@hidden>
- Date: Mon, 3 Dec 2001 21:01:43 -0800
On Monday, December 3, 2001, at 02:04 PM, Eric Schult wrote:
Can anybody explain to my why the following applet returns its path:
set myPath to ":" as alias
display dialog "You are in path:" default answer myPath
It's the magic of relative paths. Any path starting with a colon is
considered to be relative to the current working directory. (Just a
simple name -- no colons at all -- is also considered to be relative.)
Since all you've got is the colon, you get the working directory itself,
which in traditional Mac OS is normally the folder containing the
application. (An application can change this any time it wants to, but
very few do.)
The problem with this is that the default working directory isn't
guaranteed to be anything in particular, and is in fact different in Mac
OS X -- it's always the root of the file system. Using "path to me"
much more reliable.
.. and further, how you accomplish the same feat with the front-most
application, or the front-most document of an application?
"path to" has a special selector "frontmost application", so you can
just say "path to [the] frontmost application", and there you are.
There isn't any general way to get the path of the frontmost document,
because not all applications reveal the file associated with a document
window. Consult the dictionary of your favorite application.
--Chris Nebel
AppleScript Engineering