APPLESCRIPT-RELATED SYSTEM SOFTWARE COMPONENTS
A few new scriptable components are provided with Mac OS 9.1, as described in the New Features section, above.
In addition, a standard Mac OS 9.1 installation places these AppleScript-related items in the Apple Extras folder on your hard disk now in the new Applications (Mac OS 9) folder:
In the AppleScript folder, the new Script Editor 1.5.5 and a short About AppleScript document describing AppleScript generically.
Script Editor was the first Carbonized application from Apple. CarbonLib, the library that contains the Carbon code, is still undergoing rapid evolution. Mac OS 9.1 installs the then-latest CarbonLib library file in your Extensions Folder, version 1.1.1, but the Mac OS 9.1 Technote strongly urges everybody to upgrade to CarbonLib 1.2, which is now available for download from the Apple Software Updates site. AppleScripters are particularly urged to do this, because there have been reports that typing in Script Editor is slow with earlier versions of CarbonLib.
The Mac OS 9.1 CD contains additional optional items related to AppleScript in the CD Extras folder that are not installed automatically by the standard Mac OS 9.1 installation or the update but can be dragged from the CD. I don’t know that any of the CD Extras items is different than those provided with Mac OS 9. They include, in the Palm Extras subfolder of the Palm Desktop folder, an AppleScripts folder containing several folders of scripts. And in the OTExtras subfolder of the Network Extras folder, a Sample AppleScripts folder. And in the Remote Access subfolder of the Network Extras folder, another Sample AppleScripts folder containing several scripts to control Remote Access. These use the Network Setup Scripting commands, not the discontinued Remote Access Commands scripting addition. In the Place in AppleScript Stacks subfolder of the HyperCard Update folder is the old HyperCard AppleScript Reference stack from 1997. The AppleScript CD Extras folder contains a self-mounting disk image containing OSA Menu lite, iDo Script Scheduler, and a demo version of FaceSpan, all eleven of the AppleScript GuideBook Apple Help modules, a wealth of Example Scripts for use with OSA Menu, and three additional Folder Actions scripts. 2/28/01
Several changes have been made to scriptable components of the Mac OS that have been updated from their Mac OS 9.0.4 versions.
Apple Remote Access control panel application
Mac OS 9.1 updates Apple Remote Access to version 4.0. The old Remote Access Commands scripting addition is not installed with Mac OS 9.1 because it is not compatible with Remote Access 4.0. However, it is not automatically removed when updating from an earlier version of Mac OS, so you may want to remove it manually if it still exists in your System.
Scripts using any of the commands provided by Remote Access Commands should be rewritten to use Network Setup Scripting, instead. Examples can be found in the Open Transport (Networking) AppleScript Guidebook module. Apple’s Chris Espinosa has been widely quoted as saying,
We moved the functionality of the Remote Access Commands scripting addition into Network Setup Scripting several versions ago, in Mac OS 8.6. As with most product obsolescence plans, we staged its removal from the OS.
As noted below in the New Bugs in Mac OS 9.1 section, however, the Status property in the Remote Access configuration class defined in Network Setup Scripting does not work correctly in Mac OS 9.1.
The Protocol property of the Remote Access configuration class in Network Setup Scripting still refers to ARAP, although the ARAP capability has been removed from Apple Remote Access 4.0.
Apple System Profiler application
The Apple System Profiler contains these terminology changes: AtEase is now At Ease, MultipleUses… is now Multiple Users…, StartupDisk is now Startup Disk…, and …logicboard… is now …logic board…
There are some minor and major changes to the Finder’s dictionary:
Class Application now includes a new element, View Options Window, and there is a new View Options Window class to go with it.
Class Application now also includes a new Execution State property which may assume any of these values: starting up, running, rebuilding, desktop, copying, restarting, and quitting.
There is a new optional parameter to the Put Away command, asking, which specifies whether or not to present a dialog to confirm putting this item away.
Folder Actions system extension
In the Folder Actions system extension 1.5.5, the action name and action number parameters of the Remove Action From and Edit Action Of events have been changed to using action name and using action number for readibility. Older scripts should decompile to the new form automatically.
Sherlock 2 application
The Sherlock 2 dictionary was changed to eliminate the Get and Set commands. This does not affect Sherlock’s scriptability, but only conforms to the change made some time ago whereby Get and Set were made built-in AppleScript commands, no longer to appear explicitly in dictionaries.
Sound Scripting scripting addition application
This new scriptable application in the Scripting Additions folder is described in the New Features section, above.
Standard Additions scripting addition
The Choose Application command takes two new optional parameters, multiple selections allowed, and as to specify the type of the result to be returned (application, alias to the application or file of the application).
The old New File command has been renamed as Choose File Name, with the same parameters. This makes it possible for the first time to tell the Finder to make new file and get the same behavior as make file.
In AppleScript 1.5 and later, the Round command now can take an additional enumerated parameter: as taught in school. With this parameter, numbers whose fractional parts are less than .5 are rounded towards zero, and fractional parts of .5 and above are rounded away from zero.
Startup Disk control panel application
The Startup Disk control panel application is now scriptable, as described in the New Features section, above.
USB Printer Sharing control panel application
The USB Printer Sharing control panel application is new in Mac OS 9.1. It has a dictionary, and you can in fact do things like get name of front window. But it appears to be one of those applications that has only the generic scriptability supplied automatically by the development environment in which it was created. You apparently cannot script anything specifically relating to sharing your USB printer.
WhatRoute 1.7 application
The WhatRoute application is a new optional feature, as described in the New Features section, above.
WorldText 1.0 application
The WorldText 1.0 application is a new optional feature, as described in the New Features section, above. 2/6/01
The Scriptable Finder
These new AppleScript-related features in Finder 9.1 are described in the Mac OS 9.1 Technote:
The ‘put away’ [command] now has an optional ‘without asking’ parameter… The effect of the optional ‘without asking’ parameter is to inhibit any alerts that may appear during processing of the command such as ‘This disk will re-appear when you next start the machine.’
It is now possible for scripts to determine if they are being called as part of the shutdown sequence or the restart sequence. To discover the current execution state scripts can use the Finder’s execution state property. The property includes these states: restarting, starting up, running, rebuilding desktop, copying and quitting. This feature implements a couple of long-requested improvements that many scripters will welcome. John Baxter spoke for all of us when he said on the MACSCRPT list on January 19, 2001, A script running from the Shutdown Items folder can now (one might say finally…one will say THANKS) tell whether Finder is trying to shut down or restart the machine.
One other, more minor, change in the Finder’s dictionary is described above in the Dictionary Changes section.
Scripters who work with the Finder should note that, in Mac OS 9.1, changing the name of a file or folder will change the modification date of the enclosing folder. This is a departure from previous behavior. It should make it easier for a script to identify folders whose contents have changed. 2/11/01
Several long-standing bugs in the scriptable Finder, including some remaining from at least Mac OS 8.1, have finally been fixed in Mac OS 9.1. I listed and ranked what I regarded as the eleven most important Finder bugs in the note on AppleScript 1.3.7 in Mac OS 8.6. One of these, the duplicate in place bug (no. 2 in importance, by my ranking) was fixed in Mac OS 9. Three more of these are fixed in Mac OS 9.1 (nos. 1, 6, and 9 in importance, by my ranking). All-in-all, Mac OS 9.1 is an excellent system release for Finder scripting. (Of course, scripts that may run on earlier systems must still apply workarounds to cope with these fixed bugs, as well as the old bugs that have not been fixed.)
The following AppleScript-related bug fixes in Finder 9.1 are mentioned in the Mac OS 9.1 Technote:
The Finder will now properly activate windows that it opened in response to Apple events from other applications while running as a background application when the Finder is switched to the front most application.
Items found in the temporary items folder at system startup are, once again, moved to the rescued items folder in the trash. This cures a bug in Mac OS 9 that had led to the creation of many AppleScripts and other utilities designed to work around the problem.
A problem, that has existed since Mac OS 8.5, where the ‘titled’ property of a Finder window was compiled into scripts as the resizable property has been corrected.
In previous versions of the Finder, asking for a list of creator types of all the active processes would return a list of object references instead of a list of four letter strings. This problem appears in Mac OS 8 through Mac OS 9.0.4 and was not present in Mac OS 7.x… This command has been updated so it will always return a list of four character strings…
Scripts … attempting to retrieve the names of all ejectable disks no longer fail. In the past, such scripts would abort with an error such as ‘Finder got an error: Can’t get name of every disk of desktop whose ejectable = true.’
Since Mac OS 8.5, scripts using modification and creation date properties associated with files did not work. This problem appears in Mac OS 8 through Mac OS 9.0.4 and was not present in Mac OS 7.x. This problem has been corrected… This is the longstanding bug where comparisons of some creation dates and modification dates produced erroneous results. It also affected comparisons of other numeric values (AppleScript dates are numbers). Now, all of these comparisons appear to work, allowing scripters once again to use the very fast Finder filter reference form (whose clause) to create lists of qualifying files and other Finder items. For example, every item of folder Test folder where size of it < 5000.0.
There is one fix to the Finder which I had hoped, on first reading, would resolve a longstanding Finder AppleScript bug. The Finder now supports redirection (by way of the Folder Manager APIs) of the Desktop Folder to volumes other than the startup volume. The Finder now relies entirely on the Folder Manager to determine the location of the Desktop Folder and makes no assumptions about its actual location. Unfortunately, using AppleScript to obtain the path to an item that was dragged to the desktop from a non-startup disk still reports that it resides on the startup disk.
Some have reported that, although the long-standing bug in which the Finder’s entire contents property fails on large containers still exists, it now generates an error when it fails. The error message is reportedly garbled, but the error number is reportedly -108 (out of memory). Others report a different error number. Still others assert that this behavior has existed through several revisions of the Finder, and that the generation of a testable error remains hit or miss. In the absence of confirmation from Apple, the prudent course is to assume that the Finder’s behavior is unchanged and to use the entire contents property as carefully as you can, if at all. Most report that it works reliably on relatively small containers, but not everybody accepts the about 250 items upper bound of the safe zone reported by some.