Re: osascript - path to me
Re: osascript - path to me
- Subject: Re: osascript - path to me
- From: Paul Skinner <email@hidden>
- Date: Sat, 18 May 2002 11:47:33 -0400
I don't consider the 'Path to' function broken at all. It is after
all 'path to'; the usage 'Path to me' is not even referred to in the
ASLG . 'Path to' returns
Result: alias -- the path name to the folder or application specified
It would be so simple for Script Editor simply to provide what is
universally requested: consistency in interpreting path to me, so that
the path to the script is returned whether the script is run as an
applet or inside script debugger.
What if it's run from the Script Menu, a toolbar menu, Cron, Youpi
key or by another application? What if the script is loaded into another
script? Then who is 'me'?
So my grammatically correct question for you is 'Who do you think
'me' is'?
Time for some Ego spelunking!
The 'me' operator is defined as
ASLG p.242
The variable me refers to the current script, as in the following
example. The line
that specifies the property name could be placed at the end of the
script as well
as at the beginning.
property name : "Script"
tell document "Introduction" of application "AppleWorks"
get name of me --result: "Script"
end tell
If you open a script in an editor and run 'me' you'll see that 'me'
is the script itself.
me
--><<script>>
That is accurate. If you just created this new script then where
else could it point? If you just opened the script from a file and ran
it then I could understand that you expect and desire it to tell you
where it's source code is, but If you edit that same script, but don't
save it, then who is 'me' when you run it ? It's not the same script
that you opened!
If you want the location of the source file then say so.
property mySourceCode : alias
"Dalai:Users:paulskin:Library:Scripts:Developmental:DEV Scripts:
Personal:GMT time string"
mySourceCode
-->alias "Dalai:Users:paulskin:Library:Scripts:Developmental:DEV
Scripts: Personal:GMT time string"
Still dynamically tracks the source code file as long as you don't
save your source out to a new file. And no mucking about with the way
'me' works!
There are no other (reliable and simple) ways for a script to find its
resources. It is a basic need that should be met and for which
thousands of users would be greatfull.
On Friday, May 17, 2002, at 09:01 PM, Christopher Nebel wrote:
The meta-question here is "why does your script need to know where it
is?" The typical answer to this is "so it can locate some related
resources it needs", which leads to the counter-question "why aren't
you using AppleScript Studio to create an application bundle?"
And On Friday, May 17, 2002, at 11:42 PM, Timothy Bates replied:
A. Doesn't run on 80% of their client desktops
B. Requires a developer package
C. Is MUCH harder to use for a simple script
D. Gives them zero benefit over script editor.
I'd question D in this case.
The solution above wouldn't help you if you distribute this script
as an application. Who knows where the user might put the file? And you
pointed out this as all about portability. But that's what 'Path to'
does!
property mySourceCode : path to application"GMT time string"
mySourceCode
-->alias "Dalai:Users:paulskin:Library:Scripts:Developmental:DEV
Scripts: Personal:GMT time string"
As the ASLG points out this works for applications or folders only.
But right now, I can't think of an instance where a compiled script file
could be executed without someone knowing it's path already.
Caveat: Any resources you put in the same folder as the application
might have been deleted by the user, or the app could have been pulled
out of it's distribution folder and put on the desktop. Bundles solve
these problems.
In my opinion 'me' is just not the right way to ask for the
location of the source script file. So, my last comment is: Leave 'me'
alone!
On Saturday, May 18, 2002, at 04:25 AM, Christopher Nebel wrote:
On Friday, May 17, 2002, at 08:42 PM, Timothy Bates wrote:
It would be so simple for Script Editor simply to provide what is
universally requested: consistency in interpreting path to me, so that
the path to the script is returned whether the script is run as an
applet or inside script debugger.
There are no other (reliable and simple) ways for a script to find its
resources. It is a basic need that should be met and for which
thousands of users would be greatful.
Would you care to write a bug on this? No one else ever has that I can
find.
--Chris Nebel
AppleScript Engineering
--
Paul Skinner
_______________________________________________
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.