OS 9 - Package of running application file
OS 9 - Package of running application file
- Subject: OS 9 - Package of running application file
- From: Brennan <email@hidden>
- Date: Wed, 22 Jan 2003 12:38:22 +0100
Hi folks,
Apologies if this has been up before. I'm making a script which will do something
with the application file of the frontmost application in the Finder.
All works well UNLESS the app is inside a package, where the Finder has difficulty
resolving file references properly.
I decided to iterate up from the inner object, but I can't easily get the
container of objects inside packages because the Finder thinks they don't really
exist. Sometimes.
tell application "Finder"
set p to (file of (processes whose frontmost is true))
kind of p -- this causes a 'can't get' error.
container of p -- this causes a 'can't get' error.
p as string -- this causes a 'can't make into string' error.
p as alias -- this causes a 'can't make into alias' error.
end tell
If I include the coercion into the initial reference, it works;
tell application "Finder"
kind of (file of (processes whose frontmost is true))
container of (file of (processes whose frontmost is true))
(file of (processes whose frontmost is true)) as string
(file of (processes whose frontmost is true)) as alias
end tell
Note that none of this is necessary when the file is not in a package, but I can't
see a way of checking this, so I apparently have to check ALL application files to
see whether they are in a package.
This is annoying, because my solution requires that I have both the file AND its
container, so I have to make the same reference each more than once:
tell application "Finder"
set p to (file of (processes whose frontmost is true)) as alias
copy p to pp
repeat while true
set pp to ((container of pp) as alias)
set conpp to (container of pp)
set kpp to kind of pp
--log {pp, " ", conpp, " ", kpp}
if kpp is "application program package" then
return "This is it!"
else if kpp is "disk" then
return "App is not inside a package"
end if
end repeat
end tell
This works, but it seems really long winded, not to mention slow. Notice that I
have to have 'container of pp' twice . I'm also concerned that the 'kind' string
may not be internationally friendly.
Is there some neater way of knowing whether an application file is inside a
package and knowing where that package is?
This is OS 9.1. I'm using a beige machine without X and would rather not go up to
9.2.x but otherwise this is the latest Applescript implementation for OS 9
(1.8.3).
Brennan
_______________________________________________
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.