My Struggles with AppleScript (© Kevin Jaques 1996) ©(c)1995 Kevin Jaques. All rights reserved excepting that this file may be copied for non-commercial purposes, unchanged. No warranties apply. I am just a user volunteering my observations. Ever since System 7.0, I have been excited by the potential for Apple Events and AppleScript. However, I did precious little with AppleScript until last weekend. AppleScript is a scripting system built into the system, which uses Apple Events, a high­level communications protocol to communicate and control programs. Together, they work towards IAC, Inter­Application Communication. The program must be written to respond to the Apple Events (AEs). That is part of being certified as ³System 7 savvy². The minimum a program must do is respond to the Œcore¹ events, such as Open, Print, Quit. An event can come with parameters, such as a list of files, of other data, or lists of other data. A program should support its own suite. A suite is a collection of standardized events for a particular use. For instance, there is a table suite for spreadsheets, a database suite, a word processing suite, and so forth. So, scripts for one word processor should be interchangeable with those for another. If a program offers such suites, it is Œscriptable¹. AEs are typically generic, such as open, close, set, get, etc. How they function depends upon the Œobject¹ on which they are to work, such as file, document, window, pane, record, field, cell. ŒOpen¹ makes sense for any of those. In setting it up this way, subordinate items can take advantage of behaviour Œinherited¹ from their parent class, or can override it. This is called Œobject oriented programming style¹ or OOPS. The script editor is supplied with the System. You can designate the language and scripting protocol. Mine is english and AppleScript. However, since I have QuicKeys installed, I can use QuicKeys protocol in the same editor. Cool, eh? You can save as a text file, or a compiled script (which is a functional version, but which can still be opened by Script Editor and amended) or as an application. The editor itself offers little in the way of on­line help to AppleScript itself. However, its File Menu includes ŒOpen Dictionary¹. A scriptable program is supposed to contain a resource, which, last I heard was of the Œaete¹ type. This resource contains all the events and which objects they can work upon. I like that. The editor comes with several examples, including DragNDrop applets (tiny applications with minimal interfaces) to do such things as placing aliases in the startup or apple menu folders. I wrote one to put aliases in my DragNDrop folder. I actually used the Internet for practical research, and in short order, obtained Danny Goodman¹s AppleScript Reference Guide. The AppleGuide is also built into System 7. With it, if a Œguide¹ file is located in the same folder as the program you are using, then the balloon help menu contains a reference to it. When you select that, you get an outlined list of topics, which you can select and open. This Reference guide contained the contents of the Appendix to Goodman¹s Applescript book. He also wrote bibles on HyperTalk programming, and the like. Anyway, I was so proud of myself! I located and installed an on­line help for AppleScript. The file is included in this issue. Goodman endorsed ³Jon¹s Commands² a set of AppleScript handlers, so I got that and include it too. From the Editor, you can tell it to record. Then, if the program is also Œrecordable¹, you just go and do the stuff you want the program to do, come back to the editor, and find the program written. Of course touch­ups and conditions would have to be added. I found AppleScript to be much like HyperTalk, already noted for being understandable and flexible, but AppleScript is better. This is an actual quote from my script, ³show (every record of database theFile whose cell "RecNum" begins with thePrefix². You see the weird formatting? You can set the editor to format each type of thing in the script a certain way, so that commands, comments, variables, parameters, etc., are instantly recognizable, and more importantly, you can see how the editor interprets what you wrote. Filemaker 3.0, a review of which is included this month, is scriptable and recordable. Further, it comes with a database which has an excellent description of Apple Events in general, things like names, ids, parameters. The database has fabulous tables and maps and lists of the AEs that Filemaker 3.0 supports. It also comes with many examples of scripts to control Filemaker. It also comes with queer gaps in what it can do, so scripting becomes more essential. So, I am pleased to advise, I wrote an AppleScript which actually works, and is actually useful, after years of trembling in anticipation. Sorry, that¹s all the time I have. This My Struggles with AppleScript was delivered by: Kevin Jaques, B.A. LL.B. of the Jaques Law Office #101 - 2515 Victoria Avenue Fax: 525­4173 Regina, Saskatchewan Home: 586­2234 email: jaques.law@dlcwest.com Tel: 359­3041 visit our web page at http://www.dlcwest.com/~jaques.law/