Wednesday, July 27, 2011

Understanding the Scalability of Applescript

AppleScript is highly scalable in size and scope. Scripts can start out small, automating a single task with a few lines of code. Over time, they can grow into multifunctional tools and awesomely complex applications. They can also be designed to adapt as business rules and requirements change. Understanding some of the different form factors a script can take is beneficial knowledge to have.

Transition Scripts

transition script is a small script that provides a simple way to transition from one context to another. These scripts might only save a few seconds each time they are used, but over time those seconds add up.
An example of a transition script is a small script that enables users to quickly open a server folder of their choice. A button on a contact record in FileMaker Pro that uses a small script to locate and open a related folder is another. A text "cleaning" script might manipulate text in the clipboard in a variety of different ways, such as removing or adding hard returns, sorting the paragraphs, adding or removing prefixes or suffixes, or quickly saving the data into a text file in a folder the user chooses.
If a user forwards or replies to e-mail with standard responses or instructions, a simple script can automatically prepare the e-mail for review. Or if a selected file needs to be sent to a group of people, it can be dropped on a script that gives the user a choice of e-mail, FTP (File Transfer Protocol), or some other method of delivery and of a list of recipients.
Tip 
People often underestimate how much time is lost navigating around a server or typing out commonly used instructions into e-mail messages again and again. Small transition scripts can make a huge impact on a workflow, especially when they are used by a large number of people.

Script Tools

script tool is a script that performs some specific function or set of functions. While the size and scope of the automated task can vary dramatically and can evolve over time, a script tool is narrowly focused, much like the tools you use in your everyday life in the garage or kitchen. They are meant to be executed on users’ machines while they wait, setting them apart from fully autonomous solutions intended to run on a servers or dedicated computers.
Note 
Script tools are probably the most popular type of scripts built with AppleScript. They are relatively easy to design and develop and they have an immediate positive effect on the user's work. Simple tools can cross the line into transition scripts while more complex ones might blur the distinction between tools and full-blown solutions.
One of the best examples of a script tool is a batch processor script. Batch processor scripts perform a limited set of functions on any number of files. They might add layers, flatten or resize images, modify file names, generate reports, look for errors, convert file types, merge or parse PDF pages, and many more similar functions.
Script tools can do just about anything. Some might create a complex folder structure for a new project or help copy standard files into a new user directory. Others may help a user create a new product sheet from one of a group of available templates. Script tools can help search documents for text overflow errors or help users connect to servers in the morning. There really is no limit to the kinds of tools a thoughtful developer can dream up.

Script Solutions

script solution is made up of one or more scripts that automate highly complex and often lengthy processes. While the size and scope of solutions can vary like script tools, a script solution is more broadly focused on a larger sequence or quantity of tasks. While a script tool might help a user create a paragraph for a catalog page, or tabulate some data, a script solution can assemble an entire catalog file from start to finish. Besides the size of the scripts, the major distinction between a tool and a solution is that the latter is intended to run with minimal to no human intervention.
A script solution might start out small and gradually expand. In fact, many times a group of script tools can merge and evolve into a solution. As they become more complex and begin to control more steps of a workflow, script solutions can expand into a multi-module solution made up of dozens or hundreds of individual script files that are managed by a primary module that orchestrates a complex workflow.
The most common type of script solution is desktop publishing automation. For example, a script can perform multiple find, sort, and export routines to gather product information from a database that will be placed and styled in a page layout document. Next, the script can find image files on a server and import, size, and position them. Throughout this process, countless business and style rules are consistently applied. Product subcategories are automatically started on a new page or in a new document. Spacing is dynamically adjusted based on the amount of content for each product. Once the file has finished building, the script can save it for review or print it to a PDF file. It might also cross-reference products and price lists, and scan the document for text overflows or other issues and report them in a dialog box, text log, e-mail, or any other communication software. The same process can apply to any type of file, including brochures, flyers, reference guides, catalogs, and more.
Script solutions can take many other forms. Some might watch folders for files to process or instructions to carry out. Others might monitor file servers and report misplaced files to administrative personnel and performance issues to technical personnel. Others may merge photos into a time-lapse movie or contact sheet. Solutions can alert, analyze, build, create, compile, convert, delete, export, import, modify, or report just about anything.

No comments: