Re: osascript - path to me
Re: osascript - path to me
- Subject: Re: osascript - path to me
- From: email@hidden (Michael Sullivan)
- Date: Mon, 20 May 2002 10:31:18 -0400
- Organization: Society for the Incurably Pompous
Timothy Bates writes:
Note: I agree with you 100% on the absolutely unambiguous expectation
that 'me' should refer to the script, and not the app that contains it,
and that 'path to me' should return the location of the script in the
filesystem when there is such a location.
>
A script need not be a file system object, but it is always the case that it
>
is either a direct file object itself (90%) of cases, or is owned by a
>
script which IS a file object: the other 10% of cases.
Not quite. It is possible to have scripts which are not file system
objects, and which are not owned by *scripts* which are file system
objects.
The most obvious is a script that has been written (or pasted into) in
an editor, compiled and run, but has never been saved. In this instance,
it seems reasonable to return the path to the app that contains the
script.
Also, some apps have a feature where you can paste Applescript code
directly into the app. I've used this in OneClick, and IIRC, you can do
the same thing in FileMaker. Again, in both these cases, you have a
script where there is no file system object containing it that is an
applescript script. Again, I think it's reasonable to return the app in
question in these cases (since that's the only file system object which
stores the script).
>
So, "path to me" can always return the path to a file, which will be
>
unambiguous and predictable.
>
>what should
>
> echo "path to me"| /usr/bin/osascript
>
> return, if not the path to the application executing the script.
>
Given the number of emails generated, I think that almost no one using
>
AppleScript has a clue what should happen with anything on the command line
>
:-) :-)
>
But ... For my money, this should return the "/usr/bin/osascript"
>
It is the same as asking what should happen in this case
>
A script file called "theScript" contains the following
>
Script innerScript
>
whereAreWe()
>
return path to me
>
end
>
end
>
>
InnerScript's whereAreWe()
>
>
What happens when we run this? Easy:
>
>
--> path to theScript's location in the file system
What path do you return when you load a script and run it, and it
contains a path to me reference. The file it was loaded from, or the
script that is running it? I think the most consistent (With what you
are proposing here) would be the file it was loaded from, if it exists.
The hard question in all this is: Are we asking applescript to return
information that it doesn't have the infrastructure to know?
The OS knows what processes are running, and what file system object is
associated with each such process. But does it know this detail about
windows within an app. Is it possible that AS can't get this
information without the app's cooperation, without adding to the
information passed to the AS interpreter during the run of a script?
If so, then apple could certainly fix Script Editor, but there'd be no
guarantee that other third-party editors would support this properly.
What does OSAMenu do?
Plus -- how do Smile and Script Debugger manage to do this right? Is
path to me generated by asking the application what its path is via
Apple Events, rather than simply reporting the path that's in the OS
database for the running process? Or do they create a new process and
pass the script's file information when running a script?
Michael
_______________________________________________
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.