Container of an app
Container of an app
- Subject: Container of an app
- From: "Joseph A. Weaks" <email@hidden>
- Date: Thu, 13 Sep 2001 20:08:56 -0500
Here's the full subroutine I'm working on. I need the routine to
find the container folder of the app it'll be working with. The
script will be used by folks on different computers from 8.1 to 9.2.
(I substituted Tex-Edit since it's more popular than the obscure app
I'm working with.)
Basically, I want to know if there's a better way to do this. Some
other errors/quesions are in the comments.
Here is what I have:
tell application "Finder"
try -- look for the default location
set AppContainer to folder "Tex-Edit Plus " of folder "Applications"
of startup disk as string
on error
try
set AppContainer to container of application file of process
"Tex-Edit Plus" as string
on error --error means either it's not running, or it has like "4.1" on the
end
try -- see if a running app has the small string
set myProcesses to name of every application process as list
repeat with x from 1 to (count myProcesses)
if item x of myProcesses contains "Tex-Edit" then
set ThisName to item x of myProcesses as string
end if
end repeat
set AppContainer to container of application file of process ThisName as
string
-- I had this nest to launch the app, but it kept causing problems,
crashing Finder, etc.
--on error
--try
-- tell application "Tex-Edit" to activate
-- tell me to activate
-- set myProcesses to name of every application process
-- repeat with x from 1 to (count myProcesses)
-- if item x of myProcesses contains "Tex-Edit" then
-- set ThisName to item x of myProcesses as string
-- end if
-- end repeat
-- set AppContainer to container of application file of
process ThisName as string
on error -- It's not running, so manually choose the container folder
set AppContainer to (choose folder with prompt "Please locate the
folder containing Tex-Edit") as string
-- Could it now permanently remember this location for future runs?
end try
end try
end try
end tell
return AppContainer
--
* * * * * * * * * * * * * * * * * * * * *
Joe Weaks
A Bible, Greek, Mac, and Scripting Nut
* * * * * * * * * * * * * * * * * * * * *