|
Script Debugger lets you run individual handlers in a script. This can be a valuable testing and debugging technique. Standard Event HandlersConsider the applet script in the illustration below. If you simply run this script, you’ll see the “Howdy!” dialog. That’s because what you’ve just run is the run handler. But what if you want to test the
![]() This does two things:
The menu you are using here — the menu that is attached hierarchically to Script > Execute, and that appears when you hold down the mouse down on the Execute button — is called the Event Handler menu. It is attached to Script > Execute, Script > Trace, Script > Step Over, and Script > Step Into, as well as to the Execute, Step Over, and Step Into toolbar buttons. The standard event handlers listed in these menus are the five standard applet events, the Folder Actions suite events (defined in StandardAdditions.osax), and the Digital Hub Actions suite events (defined in Digital Hub Scripting.osax).
The Current EventWhat does it mean to say that the script’s current event is the To alert you to the fact that there is a current event, the current event is checked in the menu, and a current event indicator appears below the toolbar of your script window: ![]() To revert the current event to being the run handler once again, choose Script > Execute > Run (again, hold down the Shift key to prevent the run handler from running when you do this). The current event indicator goes away. Parameters and the Event HistoryThe Such a handler is listed in the Event Handler menu with an ellipsis (
Script Debugger remembers each alias or list of aliases produced in this way, along with the event handler it is to be passed to. Script Debugger adds this information to the bottom of the Event Handler menu, and makes it the current event. This list of remembered event handlers and parameters is called the event history. Thus, the next time you want to test this handler with these same parameters, you just choose it from the event history (or, if it is the current event, click the Execute button). And of course you can switch from testing one handler/parameter set to testing another, by choosing that menu item from the event history. ![]() The event history is remembered until you close the script window; or you can deliberately remove it by choosing Clear Menu (which is always the last item in the Event Handler menu if there is an event history).
Other HandlersWhat if the handler you want to test is not one of the standard event handlers already listed in the Event Handler menu? No problem. You can still call just the specific handler, and it is added to the event history so that you can easily call it again with the same parameters. To do so, you take advantage of Script Debugger’s scriptability, which allows one script to call a handler in another script. Actually, you can do this for standard event handlers as well. For example, in the case of the
This calls the However, you are more likely to use this technique to test a top-level user handler. For example, suppose you have a complex script containing this top-level handler:
You can check whether this handler is behaving correctly, without the inconvenience and overhead of running the rest of the complex script. Make a new empty script window in front of the complex script, and enter and run this script:
This calls ![]() Similarly, during external debugging, an entry-point handler called by the external application is added, with its parameters, to the target script’s event history. (This happens only if the script is in debug mode, though, since otherwise this would not be external debugging.)
|
|||||||||||||||||