Another avenue for learning how to script is to study the scripts that others have written. Look at the example scripts that are supplied with the Scripting Kit. You can also watch the progress of Apple events in the Log window (AppleScript 1.1) to learn more about how scripts work. If you are using one of the third party script editors (Scripter or Script Debugger), you can watch the variables as they change.
If you are working with an application that is recordable, you can record actions in the application and then study the scripts that it produces. Since the application is "writing" the script, you will get a better idea of the commands that it understands and how they should be scripted.
Of course, you can always join the MACSCRPT mailing list, read all of the messages, and run all of the scripts that are posted and discussed. This is a bit more interactive than reading a book.
1.1 Developer's Toolkit and Scripting Kit versions both released 1/94. This version incorporated the Apple Event Manager 1.03 extension, which was previously separated, into the AppleScript extension.
A second version of the AppleScript 1.1 Scripting Kit released in April/May 1994 contains FaceSpan (formerly, Frontmost) and the Scriptable Finder.
1.0 Runtime released 9/93. The Runtime kit contained all of the AppleScript components, the Script Editor and Scriptable Text Editor, but it did not contain a manual--only the Language at a Glance stack. This version of AppleScript was included with System 7 Pro.
1.0 Developer's Toolkit released 4/93. The Developer's Toolkit included headers, sample code, and sample applications and scripting additions. It included the Scripting Language Guide and a CD and floppy.
Back to Table of Contents
You can also buy the AppleScript Developer's Kit from APDA for $199.00. This kit includes the available Addison-Wesley manuals, FaceSpan, and code for making your applications scriptable and recordable.
You can buy an AppleScript Scripter's Kit from most of the mail order houses. The price ranges from $149.00 to $179.00. This kit includes all of the manuals that you get with the Developer's kit, as well as FaceSpan and the AppleScript software. It does not include the source code.
Some developers have licensed AppleScript to ship with their programs, and the demo versions of these programs include AppleScript. For example, you can find most of the components of AppleScript in
PhotoFlash 2.0 Trial on gaea
ScriptDebugger 1.0.4 Demo
The PhotoFlash trial version installs a nearly full AppleScript 1.1, along with Drag and Drop as well. The only item it doesn't include is the Scriptable Text Editor. The Script Editor, standard OSAXen, AppleScript extension, and PPC libs are all there. The archive is 3.5mb, so it won't be completely free to download if you have to pay for your connection. The Script Debugger demo is smaller because it contains less. It includes the AppleScript extension and basic osaxen, but lacks the Scriptable Text Editor and the Script Editor.
I have seen AppleScript questions posed and answered in comp.sys.mac.programming, comp.sys.mac.hypercard, and comp.sys.mac.system on NEWS.
If you have an account on either AOL or CompuServe, you might want to check out the MacDeveloper forums.
ControlTower has also been around since the early days of Apple events. It was one of the first programs that read the aete (or dictionary) of another program. It allowed you to construct a script in much the same way that Scripter does. Michael Odawa of Simple Software wrote Control Tower. Simple Software's last address was 220 Redwood Hwy., Suite 42, Mill Valley, CA 94941, 415/381-2650.
HyperCard is arguably the oldest scripting system for the Macintosh; it has been around since 1986. While HyperTalk is easy to learn and program, HyperTalk scripts are confined to HyperCard. Programmers have made a valiant effort to extend HyperTalk by writing XFCNs and XCMDs, but HyperTalk has always been trapped inside of HyperCard. In some ways this makes it more like a macro language than a programming or scripting language. But I'm walking on thin ice in this comparison. The latest version of HyperCard (2.3) is scriptable and OSA compliant.
MacPerl is a Macintosh port of the UNIX Perl programming language. Perl (practical extraction and report language) was written by Larry Wall. Mattias Neeracher <firstname.lastname@example.org> and Tim Endres <email@example.com> have ported Perl to the Mac as a standalone application and as an MPW tool. MacPerl is primarily worth noting because Perl is a very good language for manipulating text and because it can be called from AppleScript. Mattias is working on a port of Perl 5 and an OSA component version of MacPerl. See http://www.scriptweb.com/ for pointers.
TCL [an abbreviation for Tool Command Language that is pronounced "tickle"] was created by John K. Ousterhout. In the UNIX world, it is a simple scripting language for controlling and extending applications (sound familiar?). In the Mac world TCL has already made an appearance in Pete Kehler's Alpha text editor. It is also the basis for Tim Endres application Tickle which provides a scripting environment for several common UNIX and Mac utilities. More importantly, Tim has already ported TCL as an OSA component. The most recent release of Tickle includes an OSA component version of the J language. The most recent version of Tickle can be obtained from ftp.msen.com (18.104.22.168) in the directory /pub/vendor/ice/tickle.
You can also read through the October 1995 thread on the MacScripting list which covers most of the strengths and weaknesses of both Frontier and AppleScript. You'll find it on gaea as AS-FrontierThread.txt.
Late Night Software (Mark Alldritt of Script Tools firstname.lastname@example.org or 604/929-5578) has written a replacement for Apple's Script Editor. Script Debugger is available in 68k and PPC versions, supports greater than 32k of text and allows you to step through your script and watch global variables. The current version cannot watch local variables. Script Debugger is the only script editor that is completely scriptable. This feature makes it possible to extend Script Debugger by writing attachment and extension scripts for it. You can find a demo version of it at
Reviews of Script Debugger also appeared in MacWorld November, 1995, p. 85 and in MacWEEK 11.13.95, p. 52.
Late Night Software's website is http://www.latenightsw.apple.com/
Main Event Software (email@example.com or 202/298-9595) has released their script development environment--Scripter. In addition to allowing you to step through your scripts and watch local variables, it has script building features and a collections window to store links to your most frequently used scripts. Scripter's debugging features include Observe and Instant windows which let you watch variables in your script it is running let you quickly test short scripts. If you have access to the CodeWarrior 6 CD or Symantec's C++ 8.0 CD, you will find demo versions of Scripter beta 8 on them. Scripter was reviewed in MacWEEK, 7.12.95, page 20.
Main Event's website is http://www.mainevent.apple.com/
Full Moon Software no longer sells ScriptWizard. Current customers can "upgrade" to Script Debugger for a discount.
Tom Carstensen of Evatac Software has updated his Preditor programming editor for the Mac. It is fully scriptable and recordable, and supports stylized AppleScript code. You'll find a demo version at
Besides these editors, you can also use Frontier to write and record AppleScript scripts. It doesn't provide you with pretty printing of AppleScript, but you can use its database to store your scripts in. Using Frontier also makes it easier to combine AppleScript and Fronter scripts. Unfortunately, Frontier's debugger does not work with AppleScript.
Object Master from ACIUS (408/252-4444) is a sophisticated development environment that can replace the Think Project Manager and MPW's editor, but it also supports AppleScript. You can run scripts from the editor, though they are not pretty printed.
The recently released Tickle 5.01 has interpreter windows where you can enter and run scripts. The results of the script are pasted back into the window. See TCL just above for ftp information.
Back to Table of Contents
Running recorded scripts which are compiled for you in the recording process does not always work. So if you record the first script in the "Getting Started" manual and save it as an application, it may only display the title box and then immediately quit.
This is a bug in AppleScript/Script Editor. The work around is to re-compile the script using the Script Editor. [problem reported by Marc N. Cannava; work around offered by Mark Alldritt]
Probably the slickest solution is PreFab's Player. PreFab Software's Player extension lets you select (and query) menu items and click buttons and checkboxes in applications. Player has a smaller memory footprint than QuicKeys, and it is easier to incorporate Player into your scripts than QuicKeys. Player is available for both Frontier and AppleScript.
Prefab Software's website is http://www.prefab.com
Naturally, the Internet has its own solutions. Ross Brown has written an extension called Menu Events. It allows you to control the menus in an application that is System 7 savvy though unscriptable. It is archived at
along with a companion program
James Davis (firstname.lastname@example.org) has written an AutoType osax that lets you simulate keyboard activity from a script. AutoType sends keystrokes to the front application. It is archived at
If the app has already been handled, it pulls the terminology out of AppleScript's cache. This caches exists only as long as AppleScript is in memory. When you quit the Script Editor (or whatever), it shuts down AppleScript, freeing up its memory.
If the app is not running, then AppleScript first gets its scsz resource, which has a bit which means "always send me the GetAETE event". Quark has this bit set. When this is set, AppleScript launches the app and performs the next step instead of this one. If the bit is not set, AppleScript simply plucks the aete resource out of the app and goes on to the next application.
If the app is running, it sends it a GetAETE event, which the app will either handle or, more commonly, ignore. If it is ignored, then AppleScript's system handler gets called and it plucks the aete resource out of the currently open application file and returns it. Quark, for example, handles this event itself and scans its extensions folder for extensions with terminologies and returns them to AppleScript also.
I think this is the most important advantage AppleScript's terminology system has over Frontier's. While Frontier has to know in advance about all the scriptable apps it deals with, by having the user install glue files into the object DB, AppleScript can just pick up a new app, or a new extension to an app, simply by using it. These are all displayed in the dictionary, which means that adding a new extension to Quark could change its dictionary. In theory, it wouldn't be hard to make Frontier use glue files which were stored in resources in applications to get this benefit, but that's not the way it currently works and there are benefits to the way it works now too. Personally, I think it should cache the glue resources in the db and fetch them from the apps automatically for the best of both worlds, but my opinion doesn't really matter, now does it? ;)
OK, now we have all the terminologies in a big table. AppleScript then takes the script, which is in a mess of tokens which include spaces so they aren't simply white space seperated, and crunches it down into a tokenized script resource. This is probably fairly time consuming and the most common operation when you compile over and over, although the first pass at accumulating the terminologies can take a fair percentage of the time which makes the initial compile slower.
AppleScript then decompiles the script into styled text and returns both that and the compiled script data to the Script Editor (or whatever) and the compile is done.
You cannot insert a continuation character within a string. The following script breaks because AppleScript interprets the two lines as separate statements.
--this breaks delete word 1 of paragraph 3 of document "Fundamentals " ! & "of programming"
Your freeware options are Cron 1.0.0 and Cron1.0d16. Cron 1.0.0 is a cdev and an application that can launch application and document aliases. You rename the aliases to reflect the time that you want them to launch. Cron 1.0d16 was written by Chris Johnson of GateKeeper fame. You can always find the latest version of Chris' Cron at http://gargravarr.cc.utexas.edu/cron/cron.html.
Your shareware options are Chronograph and CronTab. Chronograph has both a 68k and PPC version of the daemon. It also follows the UNIX cron format. CronTab is an older collection of AppleScript scripts and applets.
You can also find these cron programs and scripts on gaea as Chronograph1.1UR.sea, Cron1.0.0.sit, Cron1.0d16Distribution.sit, and CronTab
Ziff-Davis Publishing also has a soluton that is available in the ZiffNet forum on CompuServe. It is called T-Minus Ten and is an application and an extension. If you have a CompuServe account, you can get the file. Due to ZD's copyright restrictions, the file cannot be uploaded to any other service.
If you have more than one screen attached to your Macintosh, the 1.x version of the Display Manager software does not support resolution switching. You will need to get version 2.0 which is available with System 7.5.2 and the upcoming Update 2.0. John also provides several scripts to get you started. Be sure to read through the Read Me; it has lots of important tips and information. ScreenMode is freeware. You can find it at
The scripting addition returns true if the file is currently open and false if the file is not currently open. For example,
FileBusy "Hard Disk :gaea permissions" -->false
Back to Table of Contents
"I believe I [am] in a position to make a definitive statement on the plurality of the name osax since I helped Donald Olson make up the term. First off, they are all lowercase. In multiples, we call them osaxen. In polite company, i.e. documentation, we call them Scripting Additions.
"...[osax stands] for Open Scripting Architecture eXtensions. We wanted to call them osex, but didn't think the Apple laywers would let us get away with that.
"Also, osaxen are not limited to scripting. If you have AppleScript installed and ANY program sends an event or uses a coercion defined in an osax, it will get called. Their use is not limited to AppleScript. However, AppleScript must be present for them to get loaded and used."
Back to Table of Contents
If you are running Script Editor 1.1 on a PowerMacintosh and you have Easy Open 1.03 installed, the formatting of your scripts will be wrong. You may see one word per line or only an " on a line. This appears to be a problem only when running in native mode, but not in emulated mode. [reported by Brian Hughes (hades@COOS.DARTMOUTH.EDU) 5/10/94 and coroborated by Craig Richmond (craig@ECEL.UWA.EDU.AU)]
If you get a "Resource not found" error message when trying to open a dictionary, you are probably using Script Editor 1.0 with AppleScript 1.1. Some users have "upgraded" to the AppleScript 1.1 extension by downloading it from the Internet site of a developer who is shipping AppleScript with his product (the distribution license allows them to distribute the AS 1.1 and FaceSpan extensions and the scripting additions from AS 1.1, but _not_ the FaceSpan or Script Editors applications). The only solution is to get Script Editor 1.1 from one of the official sources or go back to AS 1.0.
The Read/Write scripting addition from shipped with AS 1.1 breaks on the PowerMacs. At least one of the tests was performed on an 8100. The versions shipping with System 7.5 are 1.1.1 and are dated mid-June 1994 and correct this problem.
[This problem was originally reported by Peter N. Lewis and coroborated by John Baxter. 5/8/94]
When running the FaceSpan Editor (which was included with AppleScript 1.1) or a droplet built using FaceSpan, 100k to 400k of system heap is used but not released when you quit either application. Kenneth Fox reported that his System heap grew from 4900K to 6500K after about 7 lauches of a FaceSpan app. He hadn't launched any other programs during his test. This is a known memory leak that Software Development Utilities (the creator of FaceSpan) fixed in a release of its FaceSpan extension
This was also fixed in the 2.0 release of the software [first posted into the list by Adam Engst (ace@TIDBITS.COM) on 3/31/94; confirmed by Kenneth Fox (email@example.com) on 4/1/94] Digital Technology can be reached through their website at www.dtint.com or by calling 1-800/FACESPAN.
In FileMaker Pro 2.0vx, there is a bug that prevents FMP from correctly sending AppleEvents to applets created with the Script Editor. Specifically, FMP confuses the pathnames to applets, and all events are sent to the most recently created applet available! This problem was fixed in the FMP 2.1v1 update, but a similar problem exists with "applications" (frontlets <grin>) created using the FaceSpan interface builder. Claris is aware of this problem, and a fix is planned for a future update. [Lee Hoong]
AfterDark is incompatible with the Apple Event Manager 1.0 that shipped with AppleScript 1.0. [I'm running a monitor card that is incompatible with AfterDark, so I can't confirm this.]
If you get the error that the Script Editor "can't access the scripting system," check the pop-up menu in the script window which determines the scripting system you are using. If you were using a scripting system like UserTalk, QuicKeys, or tcl that you have removed, the Script Editor doesn't update the menu; it actually appears blank. This is because the Script Editor always defaults to the scripting language that you used last. Barry Chern (Can't write new script!, 5 Aug 1994) originally discovered this problem. Lawrence D'Oliveiro (10 Aug 94) offered the hack of opening the AppleScript Preferences file you find in your Preferences Folder with ResEdit. You will find a "Comp" resource in it, and it contains the four-byte type code for your last chosen scripting component. Change it to your preferred component ("ascr" if you want it to be AppleScript). Then do a Get Info on the resource and set the protected bit. Note: this hack causes the error message "could not update the preferences file because of a program error" each time you quit Script Editor.
Back to Table of Contents
You can find most of the shareware and freeware AppleScript scripting additions and AppleScript-related software on the more popular Internet FTP archives. Both mac.archive.umich.edu and sumex.stanford.edu contain software. I have consolidated as much of this software as possible on gaea.scriptweb.com/pfterry/. You will find scripting additions, sample scripts, and scriptable applications in the AppleScript directory. There are also AppleScript-related files in the QuicKeys and Frontier directories.
Back to Table of Contents
Back to Table of Contents
If there is a question that you think should included send it to me. I would also like to include any bugs or problems within AppleScript or any of the scriptable programs. If you know of additional sources of information, let me know so I can include them.
Back to Table of Contents
I can be reached via the internet at:
I do read the various comp.sys.mac newsgroups, but you should always email me if you want to be sure and reach me. When I'm under deadlines, I don't read the newsgroups at all frequently.
This FAQ will always be available on gaea.scriptweb.com. If interest warrants, I'll send it to the sumex and umich archives.
Jon Pugh Jon is the original Apple event registrar and all-around helpful guy. He also has the most frequently updated freeware collection of osaxen in his Jon's Commands osax.
John W. Baxter John lives in a wet country and is another helpful guy. John answers lots of questions on the mailing list and in NEWS.
Leonard Rosenthal Leonard is the director of advanced technology at Aladdin Software, and the one responsible for making StuffIt Deluxe/Lite scriptable. He is also the creator of the wonderful OSA Menu extension.
Peter Fleck Peter maintains the HyperCard FAQ. I borrowed his format for the text version of my FAQ because it was one of the cleanest and easiest to read I'd ever seen. Thanks, Peter.
Scott Lawton and others too numerous to mention have offered support and ideas. Thanks fellers.
Other acknowledgements are included with topics.
Back to Table of Contents
Any reproduction of the information should be complete and entire and provide reference to the original source (i.e., the MacScripting FAQ) and the editor (Fred Terry), and individual authors where directly mentioned in the text. The editor would like to be informed of any reprintings and would very much appreciate a copy of the publication.
The editor takes no responsibility for any errors, omissions or misunderstandings, however induced.
Copyright 1995-1997, Fred Terry. All Rights Reserved.