Re: Determining path to script
Re: Determining path to script
- Subject: Re: Determining path to script
- From: Michael Terry <email@hidden>
- Date: Tue, 2 Mar 2004 22:33:31 -0800
On Mar 2, 2004, at 7:42 PM, Chap Harrison wrote:
In my case, I'm writing an installer script that wants to untar an
archive stored inside the bundle. I.e., the usual reason.
Chap
I was going to suggest editing the script in Script Editor's folder.
Before bundles, a common way to package script resources was at the
level of the applet, so instead of 'path to me' what you really wanted
was 'path to my container' and that's easy if your script is in the
right location.
Now that we've got bundles and a scriptable editor, it's easy and
useful to get the path dynamically whether editing or running an
applet:
on path to place
if place is me then try
return path of front document as POSIX file as alias
on error
continue path to place
end try
end path to
alias (((path to me) as string) & "Contents:Resources")
Overriding a scripting addition command here, but that obliterates
optional parameters to 'path to'; if that were a problem then just use
a different handler name.
On Mar 2, 2004, at 5:48 PM, Christopher Nebel wrote:
On Mar 2, 2004, at 12:16 PM, Chap Harrison wrote:
How do I make a script find out its own path? ...
OK, general question here: why do people want to do this? The usual
reason, as far as I can tell, is to get at "support files" for the
script -- data, templates, script libraries, and so on.
Locating resources for an applet has never been a problem, and life is
even sweeter now with bundles. What I've always been concerned about is
being able to locate resources for compiled scripts, which I write a
lot more often than applets.
I did think of another way I use 'path to me' in applets though, which
is for "command" applets in folders. I'll preface the applet names with
an invisible low ascii character so they float to the top of the column
view. Separate them from the rest of the documents and folders with a
folder with a space and blank icon and voila, a menu of
context-sensitive commands for a folder.
Mike
_______________________________________________
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.