10.4 Changes

This article describes changes to AppleScript and related tools in Mac OS X v10.4 and its updates.

Mac OS X v10.4 - AppleScript 1.10

AppleScript 1.10 is included with Mac OS X version 10.4 and requires Mac OS X version 10.4 or later. It contains many new features and enhancements, and corrects problems found with AppleScript 1.9.3 and earlier versions.

AppleScript 1.10 can use scripts developed for any version of AppleScript from 1.1 through 1.9.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.10 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.

Special Notes

  • Scripts that compare AppleScript version numbers using string comparisons will need to be changed in order to work correctly with the new AppleScript version number. A considering numeric strings statement must be added before the string comparison so that the string “1.10” will be greater than the string “1.9.3”.

  • Scripts that compare version numbers by coercing the version class to a real number and then doing numeric comparisons will need to be changed. The coercion from version to real has been changed to allow the second and third parts of the version number to be 0..15 instead of 0..9. As a result, the version 1.2.3 will now coerce to the real number 1.0203. Previously, it would coerce to the real number 1.23.

  • Scripts that compare AppleScript version numbers, and which need to run on AppleScript 1.10 as well as earlier versions of AppleScript, should do numeric comparisons using the Gestalt version number. The Gestalt version number can be obtained using the system attribute "ascv" command.

  • String concatenation now uses the richer of the two operands. If either operand is Unicode, the result will be Unicode.

  • The path to me command now returns the correct result for compiled scripts, including those that are run using the run script command.

  • Beginning in Mac OS X version 10.4, the mount volume command can no longer mount Mac OS 9 server volumes if the server is specified using the AppleTalk server name. The TCP server name or IP address must be used instead.

  • Do not use sudo(8) with the administrator privileges parameter of the do shell script command. Due to a bug, if sudo thinks it needs a password, it will prompt for it on a non-existent terminal and wait forever for a response, causing the script to hang. This may break existing scripts.

  • The do shell script command now runs the shell script as seteuid-root, not actually root. This creates certain differences; for instance, perl will refuse to accept -e options when seteuid-root.

  • The error codes returned by the do shell script command have changed.

  • If the with icon parameter to the display dialog command specifies an icon that doesn't exist, an error is now reported. Previously, the error was ignored.

  • The return value from the list disks command is now a list of Unicode strings. Previously, it was a list of plain strings.

  • Getting the count of the paragraphs or text items of an empty Unicode string now returns 1 instead of 0.

  • Strings that contain only a plus or minus sign, can no longer be coerced to a number.

  • The implicitly encoded text types, typeText, typeCString, and typePString, are all deprecated as of AppleScript 1.9.2, since they are incapable of representing international characters and may be reinterpreted in unpredictable ways. Additionally, typeCString and typePString do not support the full range of text coercions, and will be removed entirely in a future release. typeStyledText and typeIntlText, while they have explicit encodings, are not recommended, since they are incapable of representing Unicode-only characters like Hungarian, Arabic, or Thai. The recommended text type is typeUnicodeText.

Developer Notes

  • A new Open Scripting Architecture (OSA) API has been added that lets you get the scripting dictionary of an application as an sdef (see ASDebugging.h and sdef(5)). If the target application does not have a true sdef but does have an 'aete' or Cocoa-generated dictionary, it will translate that, so the API will work on any scriptable application. [3657719]

    OSAError OSACopyScriptingDefinition(const FSRef *ref, SInt32 modeFlags, CFDataRef *sdef);

    Parameter Descriptions

    • ref An FSRef to the application file or bundle.

    • modeFlags There are no flags currently defined; pass 0.

    • sdef If the result is noErr, a CFDataRef containing the sdef XML, which you are responsible for releasing; otherwise undefined.

    Discussion

    To provide an sdef in your application, put the sdef in the Resources folder of your bundle, and add the key OSAScriptingDefinition to your Info.plist with the value of the sdef name (e.g., MyApplication.sdef).

    Known Bugs and Limitations

    Dynamic generation of sdefs is not supported. sdefs in single-file applications are not supported.

  • A crash that occurred when calling OSAScriptError() with the kOSAErrorApp selector has been fixed. [3547609]

  • The osascript command line tool now passes the kOSAModeCompileIntoContext mode flag when compiling a text script. [3684436]

  • The osascript command line tool can now call scripts that take parameters. Any arguments following the script will be passed as a list of strings to the direct parameter of the run handler. [3165225]

New Features and Enhancements

AppleScript

  • A new Considering/Ignoring attribute has been added that affects string comparisons. The numeric strings attribute specifies that numeric substrings should be collated by their numeric value. For example, “version 1.9” is less than “version 1.10”. [3614412]

  • A new string constant named quote has been added whose value is "\"". [3618573]

  • String concatenation now uses the richer of the two operands. If either operand is Unicode, the result will be Unicode. [3375227]

  • The date class now has hours, minutes, and seconds properties. The hours property always uses a 24-hour clock. [3516702]

  • The month property of the date class can now be set to an integer. [3525546]

  • The weekday constants can now be coerced to numbers. Sunday is 1. [3639194]

  • The coercion from version to real has been changed to allow the second and third parts of the version number to be 0..15 instead of 0..9. As a result, the version 1.2.3 will now coerce to the real number 1.0203. Previously, it would coerce to the real number 1.23. [3621631]

  • A tell application "AppName" statement can now use the application’s short name (CFBundleName) if the application is currently running. [3655554]

  • If a script application (applet) encounters an error, the Edit button in the error dialog will now open the applet in the default script editor. The default script editor can be set using the new AppleScript Utility application. [3084519]

  • If an applet has a custom startup screen, the startup screen will now be displayed when the user selects the “About appletName” menu item. Previously, the generic applet About Box was displayed. [3537429]

  • If a bundled applet has a custom startup screen stored in Contents/Resources/description.rtfd/TXT.rtf, that startup screen will be displayed instead of the startup screen stored in the bundle’s 'TEXT' and 'styl' resources. Note that non-text startup screens are not currently supported. [3545405]

  • Bundled applets now display localized menus and dialogs. [3847125] [3933933]

  • The applet startup screen dialogs and error dialogs now conform to the Aqua Human Interface Guidelines. [3545405] [3535392]

  • The applet About Box has been updated. [2632525]

Standard Additions

  • The with prompt and with title parameters to the choose application command now support Unicode text. [3526680]

  • The choose application dialog now remembers the column widths. [2680232]

  • The choose file and choose folder commands now have a showing package contents parameter that specifies whether packages should be treated as folders. The default is false. [3616391]

  • The of type parameter to the choose file command now accepts either a list of file types or a list of type identifiers. [3226364]

  • The choose from list command now has a with title parameter that specifies the title of the dialog. By default, the dialog does not have a title. [3722157]

  • The choose from list command now supports Unicode text. [3318667]

  • The choose from list command now supports long prompts and multi-line prompts. [2641867]

  • The choose from list dialog now allows a text item to be selected by typing the first few characters of its name. [3497349]

  • The choose from list dialog now supports full keyboard access. [2748218]

  • A new choose remote application command has been added that enables the user to choose a running application on a remote machine or on the local machine. [2763939]

  • The choose URL command now supports CIFS file servers. [3444824]

  • A new display alert command has been added that displays a standard alert dialog that conforms to the Aqua Human Interface Guidelines. [3580135] Note that standard alert dialogs have the following restrictions:

    • A default button is required. The right-most button will be the default button unless the user specifies otherwise using the default button parameter.

    • The cancel button cannot be the same as the default button.

  • The display dialog command now has a cancel button parameter that specifies the name or number of the cancel button. [3422345]

  • The display dialog command now has a hidden answer parameter that specifies whether editable text should be displayed as bullets. The default is false. [1622240]

  • The display dialog command now has a with title parameter that specifies the title of the dialog. By default, the dialog does not have a title. [3601825]

  • The default answer parameter to the display dialog command now supports Unicode text and linefeeds. [3332444] [3316708]

  • The with icon parameter to the display dialog command now accepts an alias or file reference to a .icns file. [3437405]

  • The display dialog dialog now supports full keyboard access. [3272416]

  • The display dialog dialog now uses Aqua icons for note, caution, and stop. [3437405]

  • The display dialog dialog now conforms to the Aqua Human Interface Guidelines. [3438825]

  • The do shell script command now displays the Mac OS X authentication dialog in order to obtain administrator privileges. [3004723]

  • The do shell script command now has a user name parameter that specifies an administrator account. This parameter can be used along with the password parameter and the administrator privileges parameter in order to execute commands as an administrator without displaying an authentication dialog. [3004723]

  • The info for command now has a size parameter that specifies whether the size of the item should be returned. The default is true. [3566020]

  • The info for command now returns the type identifier for files. [3226360]

  • The info for command now returns the short name (CFBundleName) for applications. [3655608]

  • The info for command now returns the busy status for packages. The busy status is set to true if the package is marked as incomplete (kExtendedFlagObjectIsBusy). [3675978]

  • The info for command now sets the busy status for non-bundled files to true if either the file is marked as open (kioFlAttribFileOpenBit) or the file is marked as incomplete (kExtendedFlagObjectIsBusy). [3976012]

  • The list disks command now supports disk names that contain Unicode characters. The return value from the list disks command is now a list of Unicode strings. Previously, it was a list of plain strings. [3513241]

  • A new localized string command has been added that returns a localized string for a specified key. [2857256]

  • The path to command now has a folder constant for the Automator workflows folder. [3748836]

  • The path to me command now returns the correct result for compiled scripts, including those that are run using the run script command. [3634573]

  • A new path to resource command has been added that returns an alias to the specified resource. [3177652]

  • The say command now accepts Unicode text and numbers as the direct parameter and as the displaying parameter. [3380562]

  • A new system info command has been added that returns a record containing information about the system. [3611016]

Bug Fixes

AppleScript

  • Strings that contain only a plus or minus sign, can no longer be coerced to a number. [2604425] [3759051]

  • The numeric value classes, the enumerated value class (typeEnumerated), and the type value class (typeType) can now be coerced to and from Unicode text and styled text. [3333079]

  • The Unit Type value classes (e.g., miles, gallons) can now be coerced to and from Unicode text. [3567987]

  • The version class (typeVersion) can now be coerced to Unicode text. [3333229]

  • Plain text (typeText) can now be coerced to styled text (typeStyledText). [3333079]

  • A coercion from typeFileURL to object specifier has been added. [3244564]

  • Coercing a file specification (typeFSS) to an object specifier now works correctly for filenames that are longer than 31 characters. [3078972]

  • Coercing an alias to an object specifier would crash in certain circumstances if the alias could not be resolved. This has been fixed. [3556365]

  • Distance and weight conversions are now more accurate. [3627006]

  • "file://localhost" as URL no longer causes a crash. [3580636]

  • Getting the first word of an empty Unicode string no longer causes a crash. [3619870]

  • Getting an arbitrary element of Unicode text using some (e.g., some word of theUnicodeText) now produces more random results. [3479349]

  • Getting the count of a non-existent element of Unicode text (e.g., count files of theUnicodeText) now returns 0. Previously, it returned the number of characters. [3735260]

  • Getting the count of the paragraphs or text items of an empty Unicode string now returns 1 instead of 0. [3978194]

  • A problem that caused some styled text comparisons to fail when the primary language was set to Japanese has been fixed. [3528969]

  • tell application "AppName" will now look for a Mac OS X application named AppName.app before looking for a Classic application named AppName. Previously, the Classic application was found first. [2868512]

  • Long application names are no longer truncated when used in a tell statement. [2854838] [3736065]

  • Long application names are no longer truncated in the “Where is xxx?” dialog. [3874872]

  • Long volume/folder/file names no longer cause errors. [3625871]

  • Getting the POSIX path of a path string that is already POSIX now returns the correct results. [3405197]

  • Scriptable Cocoa applications that contain Resource Manager resources, but do not contain an 'aete' resource, are now recognized as scriptable. [3553719]

  • If a with timeout statement specifies a timeout of more than 8947848 seconds, the timeout will be set to 8947848 seconds. Previously, an error was reported. [3570429]

  • A compilation problem that caused the last character of an enhanced application URL specification to be removed has been fixed. [3577364]

  • Backslash characters and Yen sign characters will now compile correctly when the primary language is set to Japanese. [3765766]

  • The '¬', '÷', '≠', '≤', and '≥' characters will now compile correctly when the primary language is set to Japanese, Korean, or Chinese. [3427926] [3758459] [3828128]

  • Bundled applets created using AppleScript 1.9.x always appear to be named “applet” when targeted from a remote machine. This has been fixed for bundled applets created with AppleScript 1.10 and later. [3625938]

  • Bundled applets created using AppleScript 1.9.x erroneously display the Open in the Classic Environment checkbox in the Finder’s Get Info window. This has been fixed for bundled applets created with AppleScript 1.10 and later. [3560457]

  • The size of the internal symbol table has been increased which enables larger scripts to be compiled. [3465382]

  • The size of the internal runtime stack has been increased which enables larger static lists to be created. [3612848]

  • The default formatting is now localizable. [3381966]

  • The References formatting category is no longer used. [3394917]

  • A divide by 0 within a try block within a repeat block no longer causes a hang. [3735291]

  • Crashes that would occur in certain circumstances after garbage collection have been fixed. [3410634] [3783112]

  • Memory leaks have been fixed. [3400572] [3542919]

  • Several error reporting problems have been fixed. [3537493] [2361457] [3481518] [3382032] [3753807] [3756205] [3775760]

Standard Additions

  • The choose application, choose from list, choose URL, and display dialog commands will no longer present dialogs on remote machines. [3342807]

  • The choose application command no longer leaks memory. [3505723]

  • In Mac OS X version 10.3.x, the choose application dialog is not responsive to mouse clicks within the content area when inactive. This has been fixed. [3467405]

  • The of type parameter to the choose file command now works correctly for packages that do not contain a PkgInfo file (e.g., scripting additions). [3742878]

  • choose file of type {"MooV"} now works as expected. Previously, it allowed the user to choose any file that QuickTime could open. [3595938]

  • The choose file name dialog now recognizes packages. [4003078]

  • The display dialog command will no longer create a dialog that is too tall for the screen when given a very long string to display. [3464996]

  • The display dialog command now displays Japanese text correctly when an applet is running on a Japanese-primary system. [2812677]

  • The do shell script command now works correctly with multiple commands when the administrator privileges parameter is specified. [3466509]

  • When the administrator privileges parameter is specified to the do shell script command, the 5 minute authentication timestamp now applies only to the current script. [3004723]

  • The do shell script command now returns the correct error code (-128) if the user cancels the authentication dialog. [3446874]

  • The info for command now returns the correct file type and file creator for packages that do not contain a PkgInfo file (e.g., scripting additions). [3153056]

  • read before <delimiter> as date no longer causes an error. [3383413]

  • The run script command no longer causes a stack overflow error if the direct parameter is not specified. [3514354]

  • The using parameter to the say command now works correctly when Speech Recognition is turned on. [3055088]

  • The using parameter to the say command no longer causes an error if the specified voice is not capitalized correctly. [2361457]

  • the clipboard as Unicode text now works correctly when the clipboard contains styled text but no Unicode text. [3668725]

  • Error checking and reporting has been improved. [3523658] [3522599] [2361457] [3413730] [3446766]

  • Several errors in the Standard Additions dictionary have been fixed. [3512009] [3431746] [3632368] [3608653] [3505597]

Mac OS X v10.4.2 - Standard Additions 1.10.1

Standard Additions 1.10.1 is included with Mac OS X version 10.4.2 and requires Mac OS X version 10.4 or later. It contains changes to the do shell script command. Note that only Standard Additions has changed in this release, the AppleScript runtime has not changed and its version number remains 1.10.

Bug Fixes

Standard Additions

  • do shell script ... with administrator privileges now sets both the real and effective user ids of the script to 0. This matches the behavior in Mac OS X version 10.3.x, and corrects a number of permission troubles in Mac OS X versions 10.4.0 and 10.4.1. [4126949]

  • Using sudo(8) with the administrator privileges parameter of the do shell script command will no longer cause the script to hang. In general, adding sudo to with administrator privileges is redundant, but some scripts rely on it. [4126949]

Mac OS X v10.4.3 - AppleScript 1.10.3

AppleScript 1.10.3 is included with Mac OS X version 10.4.3 and requires Mac OS X version 10.4 or later.

Developer Notes

  • The OSAGetPropertyNames() and OSAGetHandlerNames() APIs now return all of the properties and handlers of a script object when the script object contains a parent property declaration. Previously they would only return properties and handlers that were declared before the parent property. [4179456]

  • AppleScript 1.10.3 now respects the normal rules when trying to fetch terminology from the host application: it loads an 'aete' resource if one is present, or sends an event if the application is marked as having dynamic terminology. Previously, it would always send an event. This only affects scriptable applications that run scripts in their own process. [4250843]

Bug Fixes

AppleScript

  • The delay command now yields more time to other processes. [4179466]

Standard Additions

  • do shell script ... with administrator privileges no longer slows down when called more than once in the same script. [4179474]

  • The get volume settings command now returns the correct output volume when the balance is set to the right of center. [4242153]

  • The performance of the system info command has been improved. [4182950]

Mac OS X v10.4.6 - AppleScript 1.10.6

AppleScript 1.10.6 is included with Mac OS X version 10.4.6 and requires Mac OS X version 10.4 or later.

Bug Fixes

AppleScript

  • Changes to property values are now preserved when a script is run from the Script menu. In previous versions of AppleScript, the property values were only preserved if the script returned a result. [4400567]

  • A problem that caused the path to, path to it, and path to application "AppName" commands to return the wrong result in certain situations has been fixed. [4400329]

  • A compilation problem that caused the after reference form to be converted to before on Intel-based Macs has been fixed. [4460185]

  • Crashes triggered by various Dashboard widgets and applications in certain situations have been fixed. [4400300] [4400304] [4400306] [4400309] [4400557]

  • A memory leak has been fixed. [4400420]

Standard Additions

  • A problem that could cause the choose application dialog to be invisible has been fixed. [4400378]

  • A problem that could cause choose remote application to be unable to find applications on remote machines using Bonjour has been fixed. [4400386]

Mac OS X v10.4.7 - AppleScript 1.10.7

AppleScript 1.10.7 is included with Mac OS X version 10.4.7 and requires Mac OS X version 10.4 or later.

Bug Fixes

AppleScript

  • Quitting a read-only bundled applet no longer causes an error to be reported. [4505459]

  • Compiled scripts containing dates now decompile and run correctly when transferred from PowerPC-based Macs to Intel-based Macs (and vice-versa). [4525261]

  • delay commands and on idle handlers no longer conflict. [4508927]

  • Concatenating an empty record no longer causes a crash. [4510216]

  • A crash that could occur in certain circumstances when copying large nested script objects has been fixed. [4510228]

  • A memory leak has been fixed. [4505510]

Standard Additions

  • Specifying a data type of "TEXT" for a read or write command (e.g., read fileRef as "TEXT") no longer causes an error on Intel-based Macs. [4508534]