• 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: Where am I?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where am I?


  • Subject: Re: Where am I?
  • From: Paul Berkowitz <email@hidden>
  • Date: Mon, 17 Sep 2001 11:28:52 -0700

On 9/17/01 9:07 AM, "Rebecca Felts" <email@hidden> wrote:

> This seems it should be simple, but I haven't figured out how to do it. I
> want a script to be able to figure out where it resides on the system,
> without using osax. The pseudocode would be something like:
>
> get path to me
>
> returning something like "Macintosh HD:myFolder:subFolder"
>
That exact code works from an _applet_ - a script saved as an application.
It will also work from a compiled script running from OSA menu (and in
Script Debugger if you choose that preference). In other applications which
have script menus, such as Tex-Edit Plus, Outlook Express, Entourage, etc.
what that gives you is the application filer of the application running the
script. However, in _most_ cases, such as Tex-Edit Plus, you know that the
Scripts folder is in the same folder as the application file. so you can get
the parent of (path to me) either via "container of" in the Finder, or by
using text item delimiters = {":"} and remove the last text item from the
path.

Then in a try block, look for

alias (containerPath as string & "Scripts:Script Name")

and if it's not there (because someone renamed it, or because the Scripts
folder is called something different in another language) you'll have to use
'choose file' to ask the user to find it, then save it in a property, set at
compile time to "", _as an alias_ (which you should do in the other cases
too), so it doesn't matter if it gets renamed again.

In the case of Entourage, you have to look for

(path to At Ease documents as string) & "Microsoft User Data:Entourage
Script Menu Items"

in a try block: it won't work outside English-speaking countries.

Outlook Express is even more complicated: some people have their scripts in

(path to At Ease documents as string) & "Microsoft User Data:Script Menu
Items"

and some in the container folder of (path to me).

(path to At Ease documents) is your Documents folder, BTW.


--
Paul Berkowitz


References: 
 >Where am I? (From: "Rebecca Felts" <email@hidden>)

  • Prev by Date: Accessing user defined functions from within an Applescript.
  • Next by Date: empty trash with locked files
  • Previous by thread: Where am I?
  • Next by thread: Re: Where am I?
  • Index(es):
    • Date
    • Thread