Re: Where am I?
Re: Where am I?
- Subject: Re: Where am I?
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 31 Mar 2001 22:13:20 -0800
On 3/31/01 9:48 PM, "Nick Quinn" <email@hidden> wrote:
>
Hi,
>
>
[MFP, so expect dumb question] I only do applescripting every 2 or 3 years
>
so I have to relearn it each time :-(
>
>
Some of my scrips are a bit mobile and get tested on one machine then used
>
on another. Instead of hard-coding the path to the folder they work on, I
>
would like simply to put the script in that folder and let it do something
>
like:
>
>
set pathToScript to the path of this script
>
>
Then fiddle with the text to get the folder path. This obviously doesn't
>
work. RTBM "5/5/99 Language Guide" doesn't enlightened me.
>
If the scripts are "applets", i.e. saved as Applications, then you can do:
set pathToScript to (path to me)
This formulation has the advantage that even if you move the script it will
still work: you could save it as a (persistent) property if that were
helpful, and it would still know where to find itself if moved. Note that
the "path" here is actually the alias, i.e. the file, itself, not the (text)
path. If for some reason you prefer the latter then change the line to
set pathToScript to (path to me as string)
None of this will work with simple compiled scripts (non-applications),
unless they are living in OSA menu.
--
Paul Berkowitz