Re[2]: Script Applet rejects first handler call
Re[2]: Script Applet rejects first handler call
- Subject: Re[2]: Script Applet rejects first handler call
- From: Deivy Petrescu <email@hidden>
- Date: Fri, 3 Aug 2001 09:33:09 -0400
At 7:06 PM -0400 8/1/01, email@hidden wrote:
This passage is discussing what happens if you don't have a script application
saved as "Stay Open", and you try to send it an event. It gets the implicit
"Run" event, runs, exits, and then the handler event gets sent to the departed
application. Elvis has left the building.
The focus of the bug we're discussing is related to what's in the AppleScript
Language Guide just before the section quoted. There the Guide notes that a
script application handles events on a first-in, last-out manner.
I've already
discussed why I think this model makes for trouble for the scripter, and a
first-in, first out queue would be nicer. But under 1.6, the problem is that
you get an error. Its not a problem with a handler call interrupting the run
call, but the script application responding to the handler call with a -1708
error (errAEEventNotHandled). I'm guessing that under 1.6, the
applet shell is
responding to the "run" event before it has completed enumerating the script's
handlers.
The bottom line, for me, is that to call any application from an AppleScript,
you just use the command,
tell application "SurfWriter" to hang ten
The script writer shouldn't have to worry about waiting for the application to
start up and become ready for the next event, or check if it needs to be run
yet. It should just work. Particularly for script servers, CGI scripts, and
other "background engine" types of processes. The user may shut them down, or
they may die, or the may intentionally shut themselves down every few hours to
release resources, prevent memory leaks, or stop bit rot. There may
be multiple
clients all trying to get service. Who's in charge of starting and
stopping the
server? It should work the way it always has, with the server
being started if
needed, and the clients free from the need to test and launch the server.
A script saved as stay open is the same thing as a running script
while this script is running.
Whether you like this behaviour or not, it is not the point. It is
stated there in the guide as a behaviour of a script application and
any other application. The example uses SimpleText. If the
application is not running, whatever is the nature of the app, a
launch is recommended. As for first in last out or first in first
out, this is also documented, as you pointed out, thus is not a bug.
I was not questioning if this is the best way to deal with all apps
or a different procedure should be adopted. As far as my reading is
concern, what you wrote and what Chris (Nebel) reported as bug, is
what I read in the guide as paths to avoid.
If the error message is the problem, I would not call it a bug either.
As being a suggestion for a different approach I do understand your
point. However, reading your email many times ( may be I am slow) I
read the guide as telling you "don't do that!". And if launching
solves the problem, I think the guide proposes a solution as well.
If you respond to this letter and it takes me a while to post
something, I am sorry, I am disconnecting momentarily and putting
forward to all people who kindly enough forward messages to the
remaining people on this list!
Regards
Deivy