Fri, Mar 21, 1997 at 10:47:48 AM
The author of Script Debugger comments on the Apple Event Interface for External Editing.
Hi Folks,
I've just joined the MIDAS mailing list, so please forgive me if this has already been covered.
After looking at Dave's proposal for an external editing AE interface, I would like to suggest the following modifications.
1 - For the Save and Closed events, have the Suite ID of these events remain constant rather than using the creator code of the client app. This would make it much simpler for server applications to do internal event dispatching. In Script Debugger, for example, events of all kinds can come from scripts and other sources, and having to adapt to differing creator codes when recognizing Save and Close events would be a problem.
2 - Presently, the standard puts all control of the editing session in the hands of the user through the server app (not a bad thing). There is the case where the client app needs to force the end of an editing session (lets say the client app is shutting down for example). In this instance, the client needs to be able to send an event to the server which gets the current content and ends the editing session.
In Script Debugger, this is done using Script Debugger's existing Object-Model scripting interface. When you issue an edit/EDIT event, Script Debugger returns the object spec for the newly created editing window/document in the result of the event. You can then issue standard AE Registry Save, Close or Delete, GetData and SetData events using the object spec to Script Debugger to control the editing session.
I recognize that this is overkill for the external editing interface, so here is my idea: allow the client to send a Close event (as defined in Dave's spec.) to the server. The event would include the session ID, and a parameter indicating the save state:
- kAEYes = return whatever content is in the editing session
- kAENo = abandone the content in the editing session
- kAEAsk = prompt the user to confirm the save.The result of this event would be the content being edited (or nothing of the save state is kAENo).
One final point which relates to error handling on client generated Close events. Since AppleScript's are stored as compiled code, when a script editor gets the close event it will need to compile the script to get the data which will be returned. Its quite possible that the compilation will fail due to a syntax error, and so the Close event will return an error. The client needs to interpret appropriatly (ie the session is still open).
Also, the close event may return the userCanceledErr error if the user presses Cancel in response to kAEAsk.
Cheers
-Mark, alldritt@wimsey.com