Re: Just curious
Re: Just curious
- Subject: Re: Just curious
- From: Matthew Smith <email@hidden>
- Date: Thu, 21 Nov 2002 07:44:41 +1100
on 21/11/2002 03:10, Wallace, William at email@hidden
wrote:
>
For the following, please bear in mind that I'm still in the poking around
>
and exploring stage of learning AppleScript. I'm just a little mystified by
>
some quirky behavior that I stumbled upon.
>
>
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).
Quit sends a 'quit' event to an application. In this instance it is the
Script Editor, as this is the target application. Of course it can't quit,
as it is running your script.
>
If I save this as an application:
>
>
display dialog "Pointless!" giving up after 3
>
tell application "quitter" to quit
Apparently you have called your script application "quitter". AppleScript
sends it the quit event. You won't be able to run it from the Script Editor
window as the script is not an application. It is a piece of AppleScript
running in the application Script Editor. It will try and find an
application called "quitter" and send it a quit event.
AppleScript works by sending events to applications. The quit event must go
to an application. This means you cannot really run a script designed to be
an application from within the Script Editor, as the application will be the
Script Editor and not your script. When you want to use quit, you are
probably better off to write 'my quit' or 'tell me to quit, than 'tell
application "quitter" to quit. Me and my are words to refer to the current
target (application).
The only time you ever need to tell you script to quit is when it is a
stay-open application. You don't need to do it as a compiled script. It will
end once it gets to the end of the code. This is also true for non-stay-open
application scripts.
--
Matthew Smith
_______________________________________________
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.