Re: tell application "<some application>" to quit...
Re: tell application "<some application>" to quit...
- Subject: Re: tell application "<some application>" to quit...
- From: "Bob.Kalbaugh" <email@hidden>
- Date: Sun, 02 Sep 2001 16:00:29 -0500
on 9/2/01 4:58 AM, Emmanuel at email@hidden wrote:
>
At 18:27 +0200 1/09/01, Paul Berkowitz wrote:
>
>
> tell app "whatever"
>
> activate -- for those that need it
>
> try
>
> set n to (count windows)
>
> repeat with i from n to 1 by -1
>
> set theWindow to window i
>
> close theWindow saving no
>
> end repeat
>
> on error
>
> beep 3 -- get your attention for the next command!
>
> end try
>
> quit
>
> end tell
>
> --
>
> Paul Berkowitz
FTR - I ran this script on QuarkXPress and it produces errors in the repeat
statement because QXP considers palettes to be windows and palettes don't
have any new information to save (I guess). I imagine changes to information
in palettes is probably automatic or handled some other way. Also, they
appear to beat out the document window in the hierarchy so the first window
that the script tries to close is a palette.
>
In fact, it would be more advisable to be still more prudent.
>
>
It can happen that when you close a given window, some other window[s] get
>
closed automatically. "close" can decrement the number of windows by more
>
than one. Your proposition would leave some windows opened.
>
It might be better to 1. build the list of the windows, 2. try gently to
>
close each one.
>
>
----------------- much tested ...
>
tell app "whatever"
>
repeat with theWind in (every window as list)
>
set theWind to contents of theWind
>
try
>
tell theWind to close it saving no
>
end try
>
end repeat
>
end
>
>
Emmanuel
This script however, dutifully closes the document window(s) and also the
palettes, but this might not be what a scripter intends to do. Ordinarily
quark will keep any palettes you have open available for each and every
document, but using this script method forces one to go back and reopen
them. My guess for why this script doesn't error when trying to close a
palette window is because it speaks directly to the window and the window
ignores the "saving no" part. (dunno for sure)
At any rate, all of this leads me back to the statement I made in my
original post. I don't think there is any easy *universal* way to quit
applications. Each one is different. But please, somebody prove this
otherwise.
I'm trying to develop a script to use for when I've been frantically working
and come to a pause in the flow, I can easily quit the 10-12 or so apps that
I may have open at the time, and get back to square one. It helps my train
of thought and fools me into thinking that I'm organized.
--
bob.kalbaugh
--
"Still recovering from the side effects of 'Backyard Parenting.'"