tell application "<some application>" to quit...
tell application "<some application>" to quit...
- Subject: tell application "<some application>" to quit...
- From: "Bob.Kalbaugh" <email@hidden>
- Date: Sat, 01 Sep 2001 12:12:00 -0500
Here's a questions maybe someone can help with. I find that quitting
applications with:
tell application "<some application>" to quit...
...works great for many of the ones I've tried, but creates problems when
there are open, unsaved documents. Some applications won't come to the front
with the above example and the script will just hang, carry on or quit, and
the application will NOT have quit. This is because a "Prompt to Save"
dialog is presented by the application that is "quitting" and may even be
hidden behind open windows.
Including an activate command within the tell block helps in *some cases*
because it brings the app to the front allowing me to deal with the any
prompts, however this too can sometimes produce undesirable results (see the
Quark stuff below) and only practical when used after a check process
routine. (why activate (launch) an app just to quit it)
Because I don't know of any other way, I'll usually check an app's
dictionary to see if there are better terms for dealing with a quit command.
So the questions is:
"Quit" appears to be a common term in the Standard Suite of most apps - how
come apps react differently when open, unsaved docs are involved?
Do I have to deal with each app on an individual basis because of this?
Is there *one* method for quitting *all* apps in an open, unsaved documents
situation?
Thanks for answering any of the above. My guesses are:
Developers' discretion, yes, and no. I hope I've got 'em all wrong.
--
Bob.kalbaugh
--
If anyone is interested, here's what I'm talking about, and please note that
I'm using these commands only after a process check to make sure quark *is*
running...
tell application "QuarkXPress" to quit
...causes problems when unsaved docs are present - I have to manually
activate Quark to deal with the prompt to save. And...
tell application "QuarkXPress"
activate -- deal with the prompts
quit
end tell
or
tell application "QuarkXPress"
quit saving yes -- no/ask
end tell
...almost works. Quark saves and closes any documents and DOES quit but the
process hangs *waiting* for what appears to be a reply or receipt. (I've no
idea what reply or receipt to return) Apple event times out.
Checking the dictionary, I find Menu and Menu item commands so...
Using Nigel Garvey's process check (very nice Nigel - thank you, this is
much better than what I had been using) and my tell Quark statements:
--
tell application "Finder"
set procExists to process "QuarkXPress" exists
end tell
if procExists then
try
tell application "QuarkXPress"
activate
if exists document 1 then
close documents saving yes --no/ask
end if
select menu item "Quit" of menu "File"
end tell
on error
end try
end if
--
Works beautifully! but it's a heck-of-alot-more than simply:
tell application "QuarkXPress" to quit. ?:-'
and it should probably include a better try-trap, yes?