Re: Path to me Caveat
Re: Path to me Caveat
- Subject: Re: Path to me Caveat
- From: JJ <email@hidden>
- Date: Fri, 12 Oct 2001 11:09:09 +0200
>
--begin script
>
--running in an editor or an an applet.
>
property parent : application "Finder"
>
display dialog ((path to me) as text)
>
-->"OS9:System Folder:Finder"
>
--end script
>
>
In these cases, I have no idea how to find the script's location from
>
within itself. Maybe somebody here will show me how.
property parent : application "Finder"
set MeScript to ":" & "TestScript" as alias
(":" as alias) always returns the folder containing the running script: the
Script Editor (parent: script editor/debugger/...), if the script is running
inside it, or the applet/droplet's folder (parent: script Applescript).
If you need some parents, you can "define" it into "child objects":
--- s t a r t s s c r i p t ---
tell ParentFinder to DisplayDialog()
display dialog (path to me)
script ParentFinder
property parent : application "Finder"
on DisplayDialog()
display dialog (path to me) as text
end displaydialog
end script
--- e n d s s c r i p t ---
--> "HD:System Folder:Finder"
--> "HD:Desktop Folder:TestScript"
The child object "ParentFinder" defines its own parent. So, if you delente
the "property parent..." line, it returns its "default" parent: the script.
--> "HD:Desktop Folder:TestScript"
JJ