I have a very simple script to tell one of my helper apps to
show a special dialog (it normally runs hidden in the background). I
don’t want to launch the app if it isn’t already running, but I do
want to bring up that dialog if it is running. The applescript is:
ShowMyApp.applescript:
==================
on run
tell application "System
Events"
set running to
exists application process "MyApp"
end tell
if (running) then
tell application
"MyApp" to showthespecialdialog
else
display dialog
"MyApp can not be shown, it is not running"
end if
end run
==================
When I compile this app with osacompile it fails with the
following error:
ShowMyApp.applescript:7: An error of type 1 has occurred (1)
If MyApp happens to be running on the development machine
when osacompile is invoked, it will succeed.
In proper use MyApp (a helper app) is launched from a main
app with inherited pipes set up for communication. It will exit itself
immediately if not properly run. So apparently when osacompile tries to
launch it as part of compiling the ‘tell application "MyApp" to
reveal’ line, it does not stay around long enough for osacompile to get what
it needs.
Why is it that merely compiling a script requires actually
launching the app of a 'tell application "SomeApp" ' _expression_?
I build the MyApp application before compiling this script
so the app exists to be run, but I don’t want to try to falsely force it
to run on the build machine just so I can compile a script to send it a
message. I suppose I could put the compiled script (compiled on a machine
that happens to be running that app at the time) into source control, but that
is a poor solution.
If I am going about this task the wrong way, can I get some
tips on how to solve this problem better? Perhaps I am a poor searcher,
but I didn’t find much on this issue on the apple lists or general Google
searching.
Thanks,
David Litwin