AppleScript 1.7 (Mac OS 9.2.2 & Mac OS X 10.1/10.1.1 Puma)

FIXED BUGS
Long lists of fixed AppleScript-related bugs have been made available by Apple and will not be repeated here. You should read both of these documents (which have considerable overlap but are not identical) if you need to know what works correctly now in AppleScript that did not work right in earlier versions: Mac OS X v10.1 (Technical Note TN2029 10/15/01), and AppleScript 1.7 for Mac OS X 10.1 - Release Notes.

Additional information about bugs fixed in AppleScript 1.7, not included in the documents mentioned above, appear below.

The Script Runner icon now remembers where you left it on the screen when you log out and log back in. This solves the annoying usability problem in Mac OS X 10.0, where the button would always reappear on top of open documents near the upper left corner of the screen, no matter where you left it. This fix makes it feasible to designate Script Runner as a login item using the Login pane of System Preferences; just move the button to the lower right corner of the screen, and it will reappear there every time you log in. (Of course, Apple’s new ScriptMenu application, a separate download described above, provides an even more convenient global access point for your most-used scripts.) Another fix to Script Runner is that Apple’s example scripts for use with it (and with ScriptMenu) now come preinstalled in /Library/Scripts/, instead of being located in the AppleScript folder in /Applications/, as they were in Mac OS X 10.0, so that manual installation was necessary.

It was reported that, in Mac OS 10.0, you could not tell the Finder to make an alias file to an item and give the alias a name using the optional With Properties parameter. Now, in Mac OS X 10.1, a statement like the following works correctly: ‘make new alias file to selection at desktop with properties {name:some name}’.

NEW (AND OLD) BUGS
AppleScript 1.7 for Mac OS 9.2.2 reportedly contains severe bugs (see below) relating to the use of file paths. 12/28/01

The AppleScript 1.7 for Mac OS X 10.1 - Release Notes contain a long list of known problems with AppleScript 1.7, which will not be repeated here. A few additional bug reports relating to AppleScript in Mac OS X 10.1 have appeared, as noted below.

The Choose Application doesn’t work in a Classic Script topic in the News about AppleScript section of the AppleScript Help book discloses that you cannot use the Choose Application command in the Standard Additions scripting addition to choose an application on a remote computer in a script running in the Classic environment. You will receive an Out of Memory error. The workaround is to hard code in your script the remote computer and application instead of using Choose Application.

The When I run my AppleScript 1.6 script in Classic, it can’t find its target application topic of the News about AppleScript section of AppleScript Help indicates that errors may arise if you run a script using AppleScript 1.6 in the Classic environment with program linking turned on. The preferred cure is to install AppleScript 1.7 in the Classic environment. Unfortunately, as of this writing, AppleScript 1.7 for Classic is not yet available, and the only cure for now is to turn off program linking in the Sharing panel of System Preferences.

You cannot obtain information about a process on a remote computer. According to the I can’t get process information about a remote Finder 10.1 topic of the News about AppleScript section of AppleScript, a spurious error will be generated. I wondered whether you could work around this issue by explicitly running the System Events application on the remote machine, but the problem with remote events referred to above made it impossible to test the hypothesis.

The Never Show Startup Screen setting of a script application does not work reliably, and the startup screen may not appear when the script application is run even if the setting was turned off. This, according to the My script doesn’t display a startup screen topic in the News about AppleScript section of AppleScript Help.

Apple’s Chris Espinosa has confirmed that, in AppleScript 1.5 through 1.7 in the classic Mac OS and Mac OS X, a statement like set fileName to name of file 1 of disk 1 or get modification date of file fileName of disk 1 can break with Unicode file names in certain applications. Changes in the system underlying this problem are planned.

Apple’s Chris Nebel has suggested that one might consider it a bug that the Finder will not allow you to open hidden folders, as in ‘open folder var of startup disk’. In any event, he points out that a workaround is to construct the path to the invisible folder as a string, then tell the Finder to open an alias to it.

Chris Nebel has confirmed that the Path To command in Standard Additions fails to create a system folder that is properly requested, as it should when the folder does not currently exist.

The bug in Script Editor 1.6 that makes the left pane disappear from the dictionary window after you set its default size still exists in Script Editor 1.7. Just click on the resize box in the lower right corner of the window, and the left pane will immediately reappear. When you thereafter drag to resize the window, the left pane may jump to another size, but it will still be present.

It has been reported that using the Standard Additions’ Path To command within a Finder Tell block can cause errors when referring to special folders that are recognized both by the Finder and by Path To. This issue has long existed in the classic Mac OS, as well.

In my own testing, the Finder’s Ejectable property of every volume on my desktop is True. I had been under the impression that this property should return True only for removables such as CD’s and Jaz drives; if every volume is ejectable, there seems no point in providing an Ejectable property. Worse, I can in fact use AppleScript to eject any volume on my desktop (unless it is in use; for example, when it is the Mac OS X or Classic startup disk). Don’t try this at home, but if you use AppleScript to eject an external SCSI or Firewire disk, it isn’t easy to get it back, even after rebooting.

The Finder’s Has Scripting Terminology property still does not notice scriptable applications that come in the form of bundles or packages. These include TextEdit and Sketch (both Cocoa applications) and Internet Explorer (which is bundled but is not a Cocoa application).

It has been reported that a droplet written to generate a string path for any file dropped on it fails in Mac OS X when the file’s name contains an accented character.

AppleScript access to a Status Record in Internet Connect appears not to work. One user reports that this may be due to a misspelled Apple event code in the application.

Other bugs have been reported by users, as listed below.

If you were running AppleScript 1.6 in the Classic environment of Mac OS X and had remote program linking turned on in Mac OS X, all AppleScript Tell blocks would compile to ‘tell application AEServer’ no matter what application they were originally targeted at. This had to do with the AEServer application not having a traditional signature. The cure was to turn off program linking or upgrade to AppleScript 1.7 for Mac OS 9.2.2. 12/28/01

I discovered that the Beep command in the Standard Additions scripting addition, if given an integer parameter commanding it to beep two or more times, appears not to work correctly in Mac OS X; it appears to beep only once. Apple’s Chris Nebel, after investigating this phenomenon, reported that the computer is in fact beeping the indicated number of times. However, the command has been asynchronous since about Mac OS 7, and Mac OS X is so fast on today’s fast machines that the beeps pile on top of one another and sound like a single beep. The workaround is to call beep in a counting repeat loop that encloses a do-nothing repeat loop tuned to leave a short period of silence after each beep. 12/28/01

It has been widely reported that the presence of the file ToastVideoCDSupport.component (part of Toast 5.1P2) in the /Library/QuickTime folder causes AppleScript applets to quit unexpectedly. The cure is to remove the file. 12/28/01

Apple’s Chris Nebel reported that the cron utility will not properly run a scheduled AppleScript applet that attempts to tell a user application to do something. The reason is that cron is launched at boot time and therefore its process is owned by root, while user application processes are owned by the user. Mach won’t let processes in different groups talk to each other for security reasons. Aren’t you glad you asked? 12/28/01

The Finder’s Product Version property returns an empty string, as first reported by Mike Chambers. 12/28/01

Chris Nebel has confirmed that AppleScript 1.7 will not open folders with umlauts in their names. 10/8/02

Chris Espinosa reported that the List Folder scripting addition command no longer recognizes the case where its parameter is a string, breaking some older scripts. This feature will be reintroduced in a later release. 10/8/02

Chris Nebel confirmed a bug, apparently going back to AppleScript 1.4 and never before noticed, where setting an item in a list to the result of a handler that returns no value fails to generate an error but messes up the list. 10/8/02

INFORMATION FOR DEVELOPERS
If you are a developer, you will want to install the Mac OS X Developer Tools that ship with the retail Mac OS X 10.1 product (the Developer Tools CD is not provided with the free update from Mac OS X 10.0 to 10.1). The Developer Tools CD installs a large number of tools and documents of interest almost exclusively to developers, including some relating to AppleScript.

A couple of days after the announcement of Mac OS X 10.1, Apple published Mac OS X Developer Release Notes: AppleScript 1.7, detailing a few points of importance for developers of scriptable software.

Some but not all of them are listed here:
Errors in scripts that are longer than 32K will now be reported accurately, as they never before were, but only if developers change their application code to take advantage of this new feature.
The AppleScript 1.7 compiler now accepts all three prevalent line endings: Macintosh style (carriage return, ASCII 13), UNIX style (linefeed, ASCII 10) and Windows style (CRLF, ASCII 13-ASCII 10).
Considering and ignoring attributes are now more readily available to developers.
AppleScript 1.7 gives developers a means to define access to files that do not yet exist.

In addition, Apple has released new and revised documentation for AppleScript programming in both the Carbon and the Cocoa environments of Mac OS X 10.1:
Mac OS X v10.1 (Technical Note TN2029 10/15/01) is the master TechNote for this version of the Mac OS, detailing all important changes of interest to developers. It has an unusually long AppleScript section, and additional information about AppleScript is scattered throughout. Making XML-RPC and SOAP Requests With AppleScript is a new developer document explaining how to make calls from within an application using Apple events. It includes some sample scripts showing how to make XML-RPC and SOAP requests from scripts.
AppleScript documents is a page that links to several developer documents relating to AppleScript, both in Carbon and in Cocoa. There have been some important improvements in the ability to write scriptable applications.

On the third-party front, Eric Grant has released UniversalOSAX, a free CodeWarrior plugin that allows developers of scripting additions to create a single scripting addition file that executes on all Mac platforms that support AppleScript, from 68K machines running System 7 to the latest G4’s running OS X 10.1. It includes the source for Marco Piovanelli’s AppleScript Formatting osax, slightly modified to take advantage of UniversalOSAX, provided as a well-crafted example of how to create a universal scripting addition. Eric is known to AppleScripters for several useful products, but he is perhaps best known to developers for FATCarbon, his code that allows developers to build all-in-one applications that will run both as 68K and Carbon applications. If history is any guide, UniversalOSAX will be a major benefit to all AppleScripters.

From time to time, AppleScript engineers at Apple have posted developer information on the applescript-implementors mailing list and elsewhere. For example, Chris Espinosa posted this explanation in October 2001 of why some ‘aete’ resources in scriptable Cocoa applications appear to have two different version numbers, depending on how you access them: 12/28/01

Cocoa apps by definition have dynamic terminology, and the Cocoa framework responds to the GetAETE message with the synthetic terminology. Unfortunately there are still many limitations in the dynamically-generated terminology (fairly rigid suite structure, inability to define the order of terms, some unpleasant limitations on parameter and property types, the unpleasant inclusion of ‘abstract object’ as a synonym for ‘item’). So in Terminal and other Cocoa apps we override it by adding a static ‘aete’ resource that’s based on the dynamically-created one, but has certain cosmetic changes to make it more readable and accurate.

OSAGetAppTerminology() prefers the static terminology, only returning the dynamic terminology if no static ‘aete’ exists. Sending the event manually always returns the dynamic terminology, as Cocoa catches the event and doesn’t check to see if it’s been overridden with a static resource. So, for example, if you look at the terminology of Terminal on a local machine you’ll see the resource version, but if you look at it on a remote machine (where the event is your only way to get it) you’ll see Cocoa’s.

We’ll look at this for the next rev of Cocoa. O’Reilly & Associates has an article on how to add AppleScript support to Cocoa applications. 12/28/01

Don Briggs has released Suite Modeler, a Cocoa application that acts as a dictionary editor for scriptable Mac OS X applications, at version 1.2 at this writing. 12/28/01