Re: Basic AppleScript theory
Re: Basic AppleScript theory
- Subject: Re: Basic AppleScript theory
- From: bryan <email@hidden>
- Date: Wed, 20 Nov 2002 05:41:56 -0500
William,
(Is that really your name, or just a Braveheart nom de plume?)
Try the following and the cause of the behavior will be clear:
tell application finder
activate
display dialog "Pointless!" giving up after 3
end tell
tell me to quit
You will see that the behavior is idential to what you have seen
with your versions presented. The reason for the behavior lies in
the interpretation of "me" (Kind of like "That depends on what
the definition of 'is' is." to quote another famous William.)
When run inside the editor, the 'me' refers to the editor, since it is
the application sending the commands. When run as an application
'me' refers to the application so you get the behavior you want.
What you may want to try, is to check to see if the application is
is running before quitting it.
tell application "Finder"
activate
display dialog "Pointless!" giving up after 3
set proclist to processes
end tell
set thequitter to application "quitter"
if thequitter is in proclist then tell thequitter to quit
There is a hierarchy of event interception, (which I have yet to master)
responsible for these seeming irregularities. In it's finer points; it's one
of the tougher parts of grappling with AS. (At least to my view.)
Bryan Kaufman
"Wallace, William" wrote:
>
As I'm sure you're all painfully aware, I'm an absolute beginner with AS
>
(any kind of programing/scripting for that matter), so please bear with me,
>
and I apologize if this is an annoyingly stupid question. I've just been
>
fiddling around in Script Editor (I'm still in the poking around and
>
exploring stage of AS self-tutoring) and I stumbled upon a behavior that I
>
found a little confusing. Perhaps someone could illuminate this for me.
>
>
If I enter this into a Script Editor window and run it:
>
>
display dialog "Pointless!" giving up after 3
>
quit
>
>
I get an error saying "couldn't run script because a script is running". I
>
assume that this means that the quit command was directed to Script Editor
>
which couldn't fulfill the request because it was busy running the script
>
which sent the command. If I save the above script as an application it
>
behaves how I would expect (it displays the dialog and then quits).
>
>
If I save this as an application:
>
>
display dialog "Pointless!" giving up after 3
>
tell application "quitter" to quit
>
>
It works just fine, but if I run it from the Script Editor window, the
>
dialog appears and then goes away after three seconds but the script doesn't
>
quit and the application menu blinks an alert. Script Editor becomes
>
unresponsive and I have to command-tab or click on the desktop to switch to
>
another app. Then I find (not altogether surprisingly) that the "tell"
>
statement has launched the compiled application "quitter" and then another
>
"Pointless!" dialog box is displayed. However, I noticed that the dialog box
>
either didn't show up until I switched to the "quitter" application or the
>
countdown to giving up didn't begin until I switched to the "quitter"
>
application. Once "quitter" becomes the active app, it behaves as expected.
>
However, when I subsequently switch back to Script Editor, the original
>
script appears to still be running (spinning beachball). Why? And why
>
wouldn't the launched script application just do its thing quietly in the
>
background?
>
>
-whw
>
>
PS - I'm on OS 9.2.2 with AS 1.8.3
>
_______________________________________________
>
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.
[demime 0.98b removed an attachment of type text/x-vcard which had a name of bryan.vcf]
_______________________________________________
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.