10.2 Changes
This article describes changes to AppleScript and related tools in Mac OS X v10.2 and its updates.
Mac OS X v10.2 - AppleScript 1.9
AppleScript 1.9 is included with Mac OS X version 10.2 and requires Mac OS X version 10.2 or later. It contains several new features and enhancements, and corrects problems found with AppleScript 1.8.3 and earlier versions.
AppleScript 1.9 can use scripts developed for any version of AppleScript from 1.1 through 1.8.3, any scripting addition created for AppleScript 1.5 or later for Mac OS X, and any scriptable application for Mac OS 7.1 or later.
A script created with AppleScript 1.9 can be used by any version of AppleScript back to version 1.1, provided it does not use features of AppleScript, scripting additions, or scriptable applications that are unavailable in that version.
Developer Notes
In AppleScript 1.7 and earlier, the
OSASetProperty()
call would fail frequently. This has been fixed. [2786611]Object references of the form <class> <string> have historically been sent to applications as by name object specifiers. In AppleScript 1.5 through 1.8.3, if the <string> was
typeUnicodeText
the object specifier would be sent asformAbsolutePosition
. In AppleScript 1.9 and later, object references using Unicode strings are always sent to applications usingformName
. (Note that all other scalar types, includingtypeUTF8
, are sent asformAbsolutePosition
). [2768306]Developers can now define application scriptability using an XML description, rather than old-style
'aete'
resources or Cocoa.scriptSuite
and.scriptTerminology
plist files. This makes it easier to write and edit an application terminology. A new developer tool,/Developer/Tools/sdp
, converts XML files with the.sdef
extension into either.r
files (for Carbon applications) or.scriptSuite
and.scriptTerminology
files (for Cocoa). In the future, AppleScript will read.sdef
files directly, making this conversion unnecessary. See the man pages forsdp
andsdef
for more information. Some sample.sdef
files are supplied in/Developer/Examples/Scripting Definitions
. [2912639] [2913622]
New Features and Enhancements
Standard Additions
The
choose URL
command now displays SMB and Samba servers when the File servers pulldown menu is selected. [2810506]The
mount volume
command can now connect to any file server that is supported by the Finder’s Connect To... command, including Windows (smb), Samba, and FTP servers. On some kinds of servers, theas user name
andwith password
parameters may not bypass the login dialog, but encoding the name and password in the URL (e.g.smb://myname:passwd@server.domain.com/sharename
) will mount it silently. [2855789]The
say
command supports a new optional parameter,saving to
, which specifies a file in which to save the spoken text. If this parameter is provided, the command will be silent and will instead create an audio file with the data of the spoken text. For best results, the file extension of this file should be.aiff
, which will make it useable with iTunes and other audio applications. [2898296]
Script Menu
The Script Menu menu extra that has been available for download from the AppleScript web page is now included with Mac OS X. To activate the Script menu, open the
AppleScript
folder (in theApplications
folder of your startup disk) and double-click on theScriptMenu.menu
folder. The Script menu will appear on the right side of the menu bar in all applications.Like Script Runner in previous versions of Mac OS X, the Script menu lets you execute any script while using any application. It lists all files that are present in the
Scripts
folder of theLibrary
folder of both your startup disk and your Home directory. Unlike Script Runner, the Script menu will execute both OSA scripts (saved by Script Editor) and UNIX scripts (shell scripts, perl scripts, etc.).
Folder Actions
Folder Actions are now supported in Mac OS X. Folder Actions let you attach a script to a folder, and when that folder is opened or closed in the Finder or files are changed in it, a handler in that script will be executed.
In Mac OS X, Folder Actions are handled by the System Events application, not a separate Folder Actions extension. A property in the System Events application turns Folder Actions on and off; when they are on, System Events is added to your Login Items list and starts up when you log in. Folder Actions will not be performed if the System Events application quits.
Actions are attached and removed from folders by sending commands to System Events. The same events that work with the Folder Actions extension on Mac OS 9 will work the same with the System Events application in Mac OS X; in addition, System Events supports an object model for managing actions on a folder. See the System Events dictionary for the complete set of Folder Actions events and classes.
The action events that are sent to action scripts are the same as in Mac OS 9. Terminology for these events can be found in the Standard Additions scripting addition.
There are some functional differences between Folder Actions in Mac OS X from the Mac OS 9 version. In Mac OS X, actions are assigned to folders on a per-user basis, so different users of the same machine can have different sets of actions. That means that actions attached to removable or shared disks will not take effect unless that action has been assigned on your specific user account. This is a security precaution. This also means that actions attached to folders in Mac OS 9 will not take effect in Mac OS X unless they’ve been specifically attached for a particular user account in X.
Folder badging works differently in Mac OS X than in Mac OS 9. When an action is assigned to a folder, no badge appears in Mac OS X; folders that have had actions attached in Mac OS 9 will have the Folder Action badge, but will not execute their actions unless they’ve been assigned to that user.
The contextual menu that assigns, removes, and edits Folder Actions in Mac OS 9 is not present in this version of Mac OS X. Example scripts to assign and remove Folder Actions are supplied in the
/Library/Scripts/Folder Actions
directory, and can be used directly from the Script menu.Because of changes in the Finder, many Folder Action scripts from Mac OS 9 do not work in Mac OS X. [2865598]
Bug Fixes
AppleScript
In AppleScript 1.8.2 and later, certain errors in handlers of scripts loaded via the
load script
command would cause a crash. In AppleScript 1.9 these errors produce error messages instead. [2891612]Operations that create large AppleScript objects (such as lists with thousands of elements) may fail when trying to display the object (for example, in the Results or Log window of Script Editor), though the operation itself succeeds. In AppleScript 1.8.3 and earlier this usually crashes; in AppleScript 1.9 it will signal an “out of memory” error. [2897872]
AppleScript automatically converts any result value that is returned as Unicode text in UTF-8 format into Unicode text. To convert a string value to the UTF-8 format, use the coercion
as «class utf8»
[2936516]
Standard Additions
The
do shell script
command in Standard Additions 1.8.3 and earlier could not handle file paths that contained accented or non-English characters. This has been fixed. [2848082]In Standard Additions 1.8.2 and later, the
display dialog
command does not activate the default text field when the dialog is displayed, so the user must click in it before typing. This has been fixed. [2915953]With Standard Additions 1.8.3 and earlier, the
the clipboard
command would return an erroneous value when the text on the Clipboard did not have style information. If passed to other applications, that erroneous value could cause those applications to crash. This has been fixed. [2811798]
Mac OS X v10.2.3 - AppleScript 1.9.1
AppleScript 1.9.1 is included with Mac OS X version 10.2.3 and requires Mac OS X version 10.2 or later.
Developer Notes
A new
modeFlag
has been added to the OSA API:When this
modeFlag
is set on a call toOSACoerceToDesc()
, the resulting descriptor will be fully qualified, that is, it will have as its outermost container (innermost 'from' object) an application descriptor. Historically this function assumes all object specifiers are rooted at the current application, which is often incorrect. [2879211]
Bug Fixes
AppleScript
In AppleScript 1.0 through 1.9, coercions from strings to numbers (e.g.
"12" as integer
) would fail if the string contained leading or trailing white space characters (e.g. space, tab, return, linefeed). This has been fixed. [2849044]In AppleScript 1.7, the
paragraph
element of strings was improved to recognize Mac-style, UNIX-style, and Windows-style line breaks. The same changes were not, however, made to theUnicode text
class. This has been done in AppleScript 1.9.1. [3013979]In AppleScript 1.6 through 1.9, getting a
paragraph
ortext item
of an empty Unicode string fails with an error. In AppleScript 1.9.1 an empty string is now returned as the result. [3044226]With AppleScript 1.7 through 1.9, some script-editing applications cannot open their own scripting dictionaries. This has been fixed. [2688067]
In AppleScript 1.9, long scripts (from about 3,000 lines, depending on complexity) would cause an out of memory error when being displayed. This has been fixed. [3016146]
In AppleScript 1.0 through 1.9, a long script (greater than 32,767 characters) could cause a crash when being compiled. This has been fixed. [2800857]
In AppleScript 1.0 through 1.9, an execution error that occurred near the end of a long script (greater than 28,671 characters) could result in multiple lines being highlighted in the script editor instead of just the line that caused the error. This has been fixed. [1342368]
In AppleScript 1.9 and earlier, comparing two strings will fail if one string contains more than 32,767 characters, even if the strings are obviously different. This has been fixed. [2655090]
In AppleScript 1.9 and earlier, the length of a long literal string (greater than 32,767 characters) is considered to be its actual length mod 32,768. This has been fixed. [2731384]
In AppleScript 1.6 through 1.9, compiling a script might cause it to unnecessarily launch an application referred to in a
tell
block of that script. This has been fixed. [2838223]In AppleScript 1.9 and earlier, canceling out of an EPPC authentication dialog can cause compilation errors. This has been fixed. [3006076]
In AppleScript 1.8 through 1.9, the
POSIX path
property of afile
oralias
object would return "//" for the startup disk object. While not technically incorrect this has been disturbing to those familiar with UNIX, and has been fixed. [3006675]In AppleScript 1.6 through 1.9, recording a script would crash on relatively rare occasions. This has been fixed. [3006033]
In AppleScript 1.9 and earlier, an AppleScript Studio application would crash in certain circumstances. This has been fixed. [3024472]
A crash in AppleScript 1.6 and later that occurred when using Unicode text has been fixed in AppleScript 1.9.1. [3025031]
In AppleScript 1.0 through 1.9, the expression
end of {}
has caused a crash. This has been fixed. [3014615]The expression
get name of parent
would crash AppleScript 1.9 and earlier in certain circumstances. This has been fixed. [2865830]
Standard Additions
Because of changes in the Sound Manager in Mac OS X, multiple beeps produced by the
beep
command in Standard Additions 1.6 through 1.9 have sounded like one long beep. This has been fixed. [2812503]When the
display dialog
command is used with three buttons and an icon, the dialog box is now tall enough to correctly display both the icon and the leftmost button. [3052663]In Standard Additions 1.6 through 1.9, the
mount volume
command could occasionally crash when supplied withuser name
and/orpassword
parameters. This has been fixed. [3025436]
Copyright © 2017 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2017-09-19