Mac Automation Made Simple Video Podcast > Getting Started with Handlers in AppleScript

Episode 27
Date: 11.25.2009
Duration: 00:10:57
Getting Started with Handlers in AppleScript
In this episode of Mac Automation Made Simple, Ben Waldie demonstrates how to write AppleScripts more efficiently through the use of handlers. Learn how to modularize your scripts, making them more expandable, easier to update, and more..
[View in iTunes...] [View at]

MacScripter AppleScript Article > Getting Started with Handlers (Part 1)

Getting Started with Handlers (Part 1).

Welcome AppleScript developers! Some of you may be familiar with my regular AppleScript columns in X-Ray Magazine and MacTech Magazine. I am pleased to announce that, in addition to my columns in those fine publications, I will be writing regular AppleScript columns, presently on a monthly basis, for MacScripter. Be sure to check back on a weekly basis, though, for excellent AppleScript-related columns by many other great authors!

I have chosen to begin my column here at MacScripter by providing an introduction to handlers, a topic that will end up spanning three articles . My reason for choosing this topic is that shortly, I plan to start focusing on AppleScript Studio. Since AppleScript Studio development requires heavy use of handlers, and since every AppleScript developer should be making use of handlers on a regular basis anyway, it only seems fitting to begin with this topic. Let's get started. [Read more at MacScripter...]

MacScripter AppleScript Article > Getting Started with Handlers (Part 2)

Getting Started with Handlers (Part 2).

Last month's column focused on providing an introduction to handlers, discussed the benefits of using subroutine handlers, explored writing and calling subroutine handlers, and discussed handler parameter usage.

In this month's column, we will continue discussing handlers, in preparation for using AppleScript Studio to create interface-rich AppleScript solutions that have the same look and feel of any other Mac OS X application. [Read more at MacScripter...]

MacScripter AppleScript Article > Getting Started with Handlers (Part 3)

Getting Started with Handlers (Part 3).

This month's column serves as the last in a series of columns covering handler usage in AppleScript.

Part 1 of this series introduced handlers and discussed the benefits of writing and using subroutine handlers. It also looked at writing and calling subroutine handlers, as well as proper usage of handler parameters.

Part 2 of this series discussed the scope of variables with regard to handlers, explained how to return values from handlers, and demonstrated how to call handlers from within application tell statements.

So far, our handler discussions have been focused primarily around subroutine handlers, i.e. custom handlers that you write yourself and call throughout your script. In this month's column, we will discuss another type of hander: command handlers. [Read more at MacScripter...]

MacTech AppleScript Essentials Column > AppleScript Code Libraries

December, 2006 - AppleScript Code Libraries.

If you have been reading my columns for a while (prior to my introductory series on scripting different applications), then you may know that I am somewhat of a subroutine handler fanatic. I feel that handlers are an extremely important part of AppleScript development, and that every AppleScripter should be using them quite often. Unfortunately, many AppleScript developers do not.

There are many benefits to using handlers in a script. Let's discuss a few of these briefly. Handlers provide a mechanism for modularizing AppleScript code into generic chunks, which can be called from multiple locations within a script. This can lead to more efficient script writing. Instead of spending time writing virtually the same code over and over again throughout a script, you can instead focus more time on writing a solid and reliable handler, which can be called numerous times throughout the script. Not only does this help to cut down on the total amount of code you need to write in a script, but it also helps to provide a more focused completed script. Because multiple sections of the script call the same handler code, there are typically fewer areas to troubleshoot if problems do occur during execution. Furthermore, if written modularly enough, it may even be possible to extract a handler from a script, and plug it into other scripts, potentially reducing script writing time in the future too. This leads me into the main focus of this month's column, AppleScript code libraries.

[Read more at]

MacTech AppleScript Essentials Column > An Introduction to Handlers

February, 2005 - An Introduction to Handlers.

In a previous article, you may remember that we discussed methods of writing AppleScripts to watch folders for incoming items to process. In each of the methods we discussed, we made use of handlers. This month, we are going to explore handlers in more depth. Since handlers are a fairly complex subject, the full scope of handlers will not be covered in this month's article. Rather, we will cover the basics of handlers. In future articles, we will discuss handlers in more detail. [Read more at]