10.3 Changes

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

Mac OS X v10.3 - AppleScript 1.9.2

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

AppleScript 1.9.2 can use scripts developed for any version of AppleScript from 1.1 through 1.9.1, 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.2 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

  • 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.

  • The offset command now ignores case by default and honors considering and ignoring statements with regards to case and diacriticals. See the offset section below for more information.

  • Resource-fork script files can no longer be created using store script. See the store script section below for more information.

  • The path to me command will return a path that ends with a colon when used within a script application that has been saved in the new bundled format.

Developer Notes

  • Four new functions have been added to the Open Scripting Architecture (OSA) API in Mac OS X version 10.3. The new functions enable applications to load, execute, and store scripts using any of the old (data/resource fork based) or new (bundled) script formats. The new functions are OSALoadFile(), OSALoadExecuteFile(), OSAStoreFile(), and OSADoScriptFile(). For details, see the Open Scripting Architecture Reference.

  • AppleScript now sends the subject parameter in some cases where it previously failed to. This allows applications to make the at parameter for make new optional. [3039070]

  • System terminology is now read into memory only when needed for compilation or decompilation. This reduces the memory cost for applications that simply run compiled scripts. [3142099]

  • AppleScript now preserves international characters better when compiling Unicode source. [3157261]

New Features and Enhancements

AppleScript

  • AppleScript 1.9.2 supports a new bundled format for compiled scripts and script applications (applets) that uses standard Mac OS X bundles. Compiled script bundles have the filename extension .scptd, while applet bundles have the filename extension .app. [3150267] [3150248]

  • Scripting additions can be embedded within bundled applets by placing them in a folder named Scripting Additions inside the bundle’s Contents/Resources/ folder. Note that Script Editor does not look for embedded scripting additions when editing bundled applets. Any required scripting additions must be properly installed in the normal locations during script development so that Script Editor can find them. [3314117]

  • AppleScript applets now handle incoming events in a first-in, first-out manner. Prior to AppleScript 1.9.2, applets handled incoming events in a last-in, first-out manner. [2553648]

  • The Idle handler return value can now be a real number. [3199911]

  • Real numbers can now be coerced to integers even if they have a non-zero fractional part. Rounding is used to do the coercion. [2849518]

  • The month constants can now be coerced to numbers. [2396328]

  • The date class now has a short date string property. The format of the short date string is specified by the International preference pane. [2396328]

  • Two new types were added: JPEG picture and GIF picture. [3251772]

  • The zone class has been removed since EPPC over AppleTalk is not supported in Mac OS X. [2967694]

  • When a non-URL machine name is specified, it is now assumed to be a Rendezvous name instead of an AppleTalk name. [3113390]

Standard Additions

  • The choose application dialog box now allows an application to be selected by typing the first few characters of its name. [3064133]

  • The choose application dialog box now displays localized application names. [2970962]

  • The choose application dialog box now remembers its size and position. [3141005]

  • A choose color command has been added which displays the standard color picker dialog box and returns the selected color as a list of the RGB values. The default color parameter specifies the initial color. By default, the initial color is black. [3160380]

  • The choose file, choose file name, and choose folder commands now have a default location parameter that specifies which directory should be displayed in the dialog box. [3143207]

  • The choose file and choose folder commands now have an invisibles parameter that specifies whether invisible files and folders should be displayed. The default is true for choose file and false for choose folder. [2690829]

  • The choose file and choose folder commands now have a multiple selections allowed parameter that specifies whether multiple items can be selected. The default is false. [3254466]

  • The choose file and choose folder commands now support Unicode and styled text prompts. [2836896] [3318664]

  • The choose file and choose folder dialog boxes no longer use a default prompt. The dialog box will only contain a prompt if one has been specified using the with prompt parameter. [2519050]

  • The choose file name dialog box now has a new title and default prompt. [2519050]

  • The delay command now accepts real numbers. [2812515]

  • The display dialog command now supports Unicode and can now display more than 255 characters. [3077453]

  • The do shell script command now has an as parameter that specifies the desired type of the result. The default is to return the result as UTF-8 if possible. If the as parameter is not specified and the result is not valid UTF-8, the result will be returned as typeText. [3080630] [3157877]

  • Two new properties were added to the file information class. The kind property returns the item’s kind string. The bundle identifier property returns the item’s bundle identifier, if the item is a package. [2884166] [3274781]

  • The info for command now returns the short version and long version for packages. [2913766]

  • The load script command now supports the new bundled format for compiled scripts and applets. [3177719]

  • The offset command now ignores case by default and honors considering and ignoring statements with regards to case and diacriticals. As a result of these changes, the offset command now behaves the same as other AppleScript string comparisons with regards to case and diacriticals. In AppleScript 1.9.1 and earlier, the offset command always considers case and does not honor considering and ignoring statements. Scripts that are expecting offset to always consider case will need to add a considering case statement to maintain the previous behavior. [1068386]

  • The path to command now has a folder creation parameter that specifies whether the folder should be created if it does not exist. The default is to create the folder if possible. If without folder creation is specified, an error will be returned if the folder does not exist. [3315615]

  • The path to command now has the following new folder constants: applications folder, documents folder, favorites folder, home folder, library folder, movies folder, music folder, pictures folder, public folder, shared documents, shared documents folder, sites folder, utilities folder. [2650692]

  • The path to command now has a Classic domain constant that can be used with the from parameter. [2836501]

  • The run script command now supports the new bundled format for compiled scripts and applets. [3177719]

  • The shutdown folder constant has been renamed shutdown folder to prevent confusion with the shut down Finder command. [2748241]

  • The store script command can now store into any format script file including the new bundled format script files. In addition, store script can now create a new script file in bundled format (compiled script or applet) or data-fork format (compiled script only). When creating a new script file, the filename extension determines which format is created. Resource-fork script files can no longer be created using store script but existing ones can be updated. When storing a script into an existing file, the file must be a script file; previously, the file could contain anything and an 'scpt' resource was simply added to the file. [3177719]

  • The store script dialog box is now resizable and moveable. [3148202]

  • The store script dialog box now has a new title and default prompt. [2519050]

Command Line Tools

  • The osacompile tool now supports the new bundled format for compiled scripts and applets. If the -o option is specified and the file does not already exist, osacompile uses the filename extension to determine what type of file to create. If the filename ends with .app, a bundled applet will be created. If the filename ends with .scpt, a bundled compiled script will be created. Otherwise, the resulting script will be placed in the resource fork and/or data fork of the output file depending upon what other options are specified. [3150246]

  • The osacompile tool now has a -s (stay open) option. This option is only valid when a new bundled applet is being created. The option specifies that the applet should stay open after running. [3231791]

  • The osacompile tool now has a -u (use startup screen) option. This option is only valid when a new bundled applet is being created. The option specifies that the applet should display a startup screen when launched. [3231800]

  • The osascript tool now supports the new bundled format for compiled scripts and applets. [3150246]

  • The osascript tool now reports character range information when an error occurs. [3310364]

Bug Fixes

AppleScript

  • In AppleScript 1.9.1 and earlier, pathnames of alias objects may have problems if they contain non-ASCII characters. This has been fixed. [2765349]

  • Coercing miles, yards, or feet to inches now produces the correct result. Coercing cubic yards or cubic feet to cubic inches now produces the correct result. [3251787]

  • Coercions from typeUnicodeText to typeText or typeStyledText now handle byte-order-mark characters correctly. [3115555]

  • Coercions from typeStyledText to typeUnicodeText now handle coercion failures and warnings correctly. As a result of this change, the example scripts can now be opened in Script Editor when the primary language is set to Korean. [3309458]

  • An empty with timeout statement no longer causes a crash or stack overflow. [2354124]

  • An empty considering or ignoring statement no longer causes a crash or stack overflow. [3243780]

  • The statement paragraphs 2 thru -1 of "" no longer causes a crash. [3342312]

  • Getting the characters of a very long string no longer causes a stack overflow. [3016960]

  • Getting the text items of a Unicode string now works correctly. [3136465]

  • Getting the text items or paragraphs of an empty Unicode string now returns {""} instead of {}. [3198302]

  • Getting the text items of a string now works correctly when the text item delimiters are set to {}. [3146794]

  • The arbitrary element reference form some item wasn’t very random. This has been fixed. [3044302]

  • The contains and ends with operators now work correctly on strings with more than 32,767 characters. Previously, they would always return false if they did not find a match within the first 32,767 characters of the string. [3126655]

  • The containment operators now work correctly on Unicode strings when used within an ignoring punctuation statement. Previously, they did not ignore punctuation marks correctly when doing the string comparisons. [3328867]

  • The containment and comparison operators now work correctly on Unicode strings when used within an ignoring hyphens statement. Previously, they did not ignore hyphens when doing the string comparisons. [3329084]

  • The containment and comparison operators now work correctly on Unicode strings when used within an ignoring white space statement. Previously, they did not ignore white space when doing the string comparisons. [3330635]

  • The containment operators are now much faster when used on Unicode strings. [3204625]

  • Constant Unicode strings that are specified using the data class (i.e. «data utxt») can now be coerced to typeUnicodeText and no longer cause a crash when used with the & operator. [3222690]

  • In certain circumstances, a run script command within a tell application "Finder" statement would cause a crash in previous versions of AppleScript. This has been fixed. [3380899]

  • AppleScript can now compile URLs that begin with https. [3113313]

  • AppleScript now compiles numbers larger than 4294967295 correctly. Older versions of AppleScript compile numbers larger than 4294967295 to their value minus 4294967296. [3247815]

  • Exponent math is now correct when the power is greater than 32767 and less than 65536. [3396181]

  • Adding a negative number to any date between 1/1/1904 0:00:00 and 1/19/1972 3:14:07 now produces the correct result. [3160911]

  • Subtraction operations involving dates earlier than 1/1/1904 0:00:00 now produce the correct result. [2861317]

  • Date arithmetic involving date object specifiers now works as expected instead of reporting an error that says the object specifier can’t be coerced to a date. [3187787]

  • If an error occurs while attempting to connect to a remote machine, the actual error is now reported. Previously, connection errors were converted into a generic message saying that the application’s dictionary could not be read. [3209734]

  • If a compilation error occurs near the end of a long script (more than 32,767 characters) the correct line is now highlighted in the script editor. [3089998]

  • Backslashes in strings now work correctly on Japanese systems. [3390330]

  • If a script tells an application that is not running to quit, nothing will happen. In previous versions of AppleScript, the application would be launched and then immediately be told to quit. [2589455]

  • AppleScript no longer crashes while attempting to unload an OSAX written in Objective-C. [3193941]

  • A crash that would occur in certain circumstances after garbage collection has been fixed. [3369338]

  • Memory leaks have been fixed. [3254901]

  • A couple of incorrect error messages have been fixed and a missing error message has been added. [3020705] [3290768]

  • AppleScript’s default formatting has been changed. [3032595] If you have already used AppleScript on a given machine, you will not notice this change unless you do any of the following:

    • choose Use Defaults from the Formatting dialog box in Script Editor

    • delete your AppleScript preferences

    • set up a new user (or log in on a user account that has never used AppleScript)

    • do a clean operating system install without saving or retaining user preferences

Standard Additions

  • The display dialog dialog box now handles the Return, Enter, and Esc keys correctly. [3044290] [3096706]

  • The display dialog command now reports an error if the default button parameter is set to 0, a negative number, or a number that is greater than the total number of buttons. [3051124]

  • The display dialog command now reports an error if a record is specified as the text to display. [3142086]

  • do shell script with administrator privileges now distinguishes between a cancelled authentication and a failed authentication. [3070647]

  • do shell script with administrator privileges no longer reports an authentication error if the admin user has no password. [2882577]

  • The info for command no longer returns the folder window for packages. The visible property is now correct for items whose name begins with a period. [2884166]

  • The list folder command no longer crashes when given a file instead of a folder. [3267269]

  • list folder without invisibles no longer lists items whose name begins with a period. [2767663]

  • In certain situations, the open for access command would try to create a file that already existed which would result in a “duplicate file name” error. This has been fixed. [2827608]

  • The open for access command can now create a file whose name contains slashes or colons (whichever is not the native path separator for the path style in use). [3267270]

  • The path to command now works correctly with the following folder constants: startup, startup items, startup items folder. [2650692]

  • Scripts that use the path to frontmost application command will now get the correct path when run from the Script menu. Previously, the command would return the path to System Events. [3084984]

  • The read command now works correctly when the file contains Unicode text and the before, until, or using delimiter parameters have been specified. [3013987]

  • If the run script command encounters an error while compiling the script, it now reports the actual error instead of a generic script error. [2304013]

  • A problem that caused the say command to hang has been fixed. [3196145]

  • The set volume command now sets the volume level correctly. [3268130]

  • the clipboard now works correctly if the as parameter is specified. Previously, the as parameter was almost completely ignored. [3255134]

  • the clipboard now works correctly if the as parameter is not specified. If the clipboard contains only one item, that item is returned. If the clipboard contains multiple items and at least one of the items is text, the highest quality text item will be returned. Unicode text is preferred over styled text which is preferred over plain text. If the clipboard contains multiple items but none of the items is text, the items are returned as a record. [3334818]

  • Several errors in the Standard Additions dictionary have been fixed. [2696269] [3034675] [3152145] [3292454] [3311842]

Mac OS X v10.3.2 - AppleScript 1.9.3

AppleScript 1.9.3 is included with Mac OS X version 10.3.2 and requires Mac OS X version 10.3 or later.

Developer Notes

  • In AppleScript 1.9.2, coercing an AEDesc to Unicode text will fail if the text is a null string. This has been fixed. [3439141]

Bug Fixes

AppleScript

  • In AppleScript 1.9.2, the with timeout statement does not return an error if the timeout expires. This has been fixed. [3457829]

  • When using a Japanese-primary system, scripts that compile correctly with AppleScript 1.9.1 may fail to compile with AppleScript 1.9.2. This has been fixed. [3419243]

  • In AppleScript 1.9.2, saving a blank script with Script Editor 2.0 will result in a crash. This has been fixed. [3421468]

  • In AppleScript 1.9.2, using Xcode to open a new .applescript file that was created by Interface Builder will result in a crash. This has been fixed. [3454301]

  • AppleScript Studio debugging has been improved. [3467973] Note, AppleScript Studio debugging requires Xcode 1.1.

Standard Additions

  • In AppleScript 1.9.2, the mount volume command will fail if the user name is not specified and the volume does not allow guest access. This has been fixed. [3464919]

Mac OS X v10.3.5 - Standard Additions 1.9.4

Standard Additions 1.9.4 is included with Mac OS X version 10.3.5 and requires Mac OS X version 10.3 or later. It contains improvements to the set volume command as well as a new get volume settings command. Note that only Standard Additions has changed in this release, the AppleScript runtime has not changed and its version number remains 1.9.3.

New Features and Enhancements

Standard Additions

  • A new get volume settings command has been added that returns a record containing information about the current volume settings. [3467967]

  • The set volume command now has four new parameters that enable the user to set the output volume, the input volume, the alert volume, and the mute setting (output muted). The direct parameter is now deprecated. If the direct parameter is specified, all other parameters are ignored. [3563760]

Bug Fixes

Standard Additions

  • The set volume command now sets the volume level correctly. [3268130] [3479316]