Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Next Page > Hide TOC

Open Scripting Architecture Reference

Framework
Carbon/Carbon.h
Declared in
ASDebugging.h
ASRegistry.h
AppleScript.h
OSA.h
OSAComp.h
OSAGeneric.h

Overview

The Open Scripting Architecture (OSA) provides a standard and extensible mechanism for interapplication communication in Mac OS X. It provides support for creating scriptable applications and for writing scripting components to implement scripting languages. Every Mac OS X system includes the AppleScript component, which implements AppleScript, the standard scripting language defined by Apple. However, developers can write scripting components for additional scripting languages. For conceptual information on the OSA, see “Open Scripting Architecture” in AppleScript Overview.

You need to use this reference if you are writing a scripting component or if your application needs to interact with scripting components to manipulate and execute scripts. The API described in this document is implemented by the OpenScripting framework, a subframework of the Carbon framework. For information about working with components, see Scripting Components in Inside Macintosh: Interapplication Communication.

Important:  Do not rely on the API descriptions in Interapplication CommunicationOpen Scripting Architecture Reference provides the current API documentation.

The Apple Event Manager, another part of the OSA, is implemented primarily by the AE framework, a subframework of the Application Services framework, and is documented in Apple Event Manager Reference and Apple Events Programming Guide. Applications use the Apple Event Manager to send and respond to Apple events and to make their operations and data available to AppleScript scripts.

Functions by Task

Saving and Loading Script Data

Executing and Disposing of Scripts

To execute a script, your application must first obtain a valid script ID for a compiled script or script context. You can use either the OSALoad function or the optional OSACompile function to obtain a script ID.

Setting and Getting Script Information

Manipulating the Active Function

Compiling Scripts

Scripting components can provide three optional functions that get the name of a scripting component, compile a script, and update a script ID. A scripting component that supports the functions in this section has the kOSASupportsCompiling bit set in the componentFlags field of its component description record.

Getting Source Data

Coercing Script Values

Scripting components can provide support for two optional functions which coerce data in a descriptor record to a script value and coerce a script value to data in a descriptor record. A scripting component that supports the functions in this section has the kOSASupportsAECoercion bit set in the componentFlags field of its component description record.

Manipulating the Create and Send Functions

Some scripting components provide functions that allow your application to set or get pointers to the create and send functions used by the scripting component when it sends and creates Apple events during script execution. If you do not set the pointers that specify these functions, the scripting component uses the standard AECreateAppleEvent and AESend functions with default parameters. A scripting component that supports the functions described in this section has the kOSASupportsAESending bit set in the componentFlags field of its component description record.

Recording Scripts

Script editors use these functions to allow users to control recording. Any application can use these functions to provide its own script-recording interface. A scripting component that supports the functions described in this section has the kOSASupportsRecording bit set in the componentFlags field of its component description record.

Executing Scripts in One Step

You can use these functions if you know that the script data to be executed will be executed only once. A scripting component that supports the functions described in this section has the kOSASupportsConvenience bit set in the componentFlags field of its component description record.

Copying a Scripting Dictionary as a Scripting Definition File

Manipulating Dialects

Scripting components that provide several dialects may provide five functions that allow you to switch between dialects dynamically and get information about currently available dialects. The codes for specific dialects are provided by the scripting component. A scripting component that supports the functions described in this section has the kOSASupportsDialects bit set in the componentFlags field of its component description record.

Using Script Contexts to Handle Apple Events

The optional functions described in this section allow your application to use script contexts to handle Apple events. One way to do this is to install a general Apple event handler in your application’s special handler dispatch table. The general Apple event handler provides initial handling for every Apple event received by your application. A scripting component that supports the functions described in this section has the kOSASupportsEventHandling bit set in the componentFlags field of its component description record.

Initializing AppleScript

Getting and Setting Styles for Source Data

Getting and Setting the Default Scripting Component

The default scripting component for any instance of the generic scripting component is initially AppleScript, but you can change it if necessary.

Using Component-Specific Routines

You can’t use the generic scripting component to call a component-specific routine. Instead, you must use an instance of the specific scripting component that supports the routine.

To facilitate the use of component-specific routines, the generic scripting component allows you to identify the scripting component that created stored script data, get an instance of a specified scripting component, and convert between generic script IDs and component-specific script IDs.

Manipulating Trailers for Generic Storage Descriptor Records

All scripting components must use the OSAGetStorageType, OSAAddStorageType, and OSARemoveStorageType functions described in this section to add, remove, and inspect the trailers appended to script data in generic storage descriptor records.

Miscellaneous

Creating, Invoking and Disposing Universal Procedure Pointers

Deprecated Functions

!

Warning:  Do not use the OSA debugging functions listed here. They were were not intended for public use, they do not work, and they will return an error.

Functions

ASCopySourceAttributes

Gets the current text style attributes AppleScript uses to display script text.

OSAError ASCopySourceAttributes (
   ComponentInstance scriptingComponent,
   CFArrayRef *resultingSourceAttributes
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

resultingSourceAttributes

If successful, returns a reference to an array (of type CFArray) of dictionaries (of type CFDictionary) of text style attributes; otherwise, returns nil.

The order of elements in the array corresponds to the constants defined in “Source Style Constants,” and therefore also to the names returned by ASGetSourceStyleNames. For example, the first dictionary in the array (at position kASSourceStyleUncompiledText) describes the style for uncompiled text. However, you should not rely on there being any specific number of dictionaries in the returned array—instead, count the number of items in the array before accessing any of them.

This array is a copy and the caller is responsible for releasing it, according to the rules described in Ownership Policy in Memory Management Programming Guide for Core Foundation.

Return Value

A result code. See “Result Codes.”

Discussion

A text style attribute is typically something that is meaningful to a CFAttributedString, such as the one returned by OSACopyDisplayString or OSACopySourceString. However, clients may add other attributes using ASSetSourceAttributes.

Availability
Declared In
AppleScript.h

ASGetAppTerminology

Deprecated. Use OSAGetAppTerminology instead.

OSAError ASGetAppTerminology (
   ComponentInstance scriptingComponent,
   FSSpec *fileSpec,
   short terminologID,
   Boolean *didLaunch,
   AEDesc *terminologyList
);

Return Value

A result code. See “Result Codes.”

Version Notes

Provided for backward compatibility only. Use OSAGetAppTerminology instead.

Availability
Declared In
ASDebugging.h

ASGetHandler

Deprecated. Use OSAGetHandler instead.

OSAError ASGetHandler (
   ComponentInstance scriptingComponent,
   OSAID contextID,
   const AEDesc *handlerName,
   OSAID *resultingCompiledScriptID
);

Return Value

A result code. See “Result Codes.”

Version Notes

Provided for backward compatibility only. Use OSAGetHandler instead.

Availability
Declared In
ASDebugging.h

ASGetProperty

Deprecated. Use OSAGetProperty instead.

OSAError ASGetProperty (
   ComponentInstance scriptingComponent,
   OSAID contextID,
   const AEDesc *variableName,
   OSAID *resultingScriptValueID
);

Return Value

A result code. See “Result Codes.”

Version Notes

Provided for backward compatibility only. Use OSAGetProperty instead.

Availability
Declared In
ASDebugging.h

ASGetSourceStyleNames

Obtains a list of style names that are each formatted according to the script format styles currently used by the AppleScript component.

OSAError ASGetSourceStyleNames (
   ComponentInstance scriptingComponent,
   SInt32 modeFlags,
   AEDescList *resultingSourceStyleNamesList
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

modeFlags

Reserved for future use. Set to kOSAModeNull.

resultingSourceStyleNames

A pointer to a list of style names (for example, “Uncompiled Text,” “Normal Text”) that are each formatted according to the current script format styles. The order of the names corresponds to the order of the source style constants listed in “Source Style Constants.” For example, the first name in the list (at position kASSourceStyleUncompiledText) is formatted according to the style for uncompiled text.

Return Value

A result code. See “Result Codes.”

Availability
Declared In
AppleScript.h

ASInit

Initializes the AppleScript component.

OSAError ASInit (
   ComponentInstance scriptingComponent,
   SInt32 modeFlags,
   UInt32 minStackSize,
   UInt32 preferredStackSize,
   UInt32 maxStackSize,
   UInt32 minHeapSize,
   UInt32 preferredHeapSize,
   UInt32 maxHeapSize
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

modeFlags

Reserved for future use. Set to kOSAModeNull.

minStackSize

The minimum size for the portion of the application’s heap used by the AppleScript component’s application-specific stack.

preferredStackSize

The preferred size for the portion of the application’s heap used by the AppleScript component’s application-specific stack.

maxStackSize

The maximum size for the portion of the application’s heap used by the AppleScript component’s application-specific stack.

minHeapSize

The minimum size for the portion of the application’s heap used by the AppleScript component’s application-specific heap. (See Version Notes section.)

preferredHeapSize

The preferred size for the portion of the application’s heap used by the AppleScript component’s application-specific heap. (See Version Notes section.)

maxHeapSize

The maximum size for the portion of the application’s heap used by the AppleScript component’s application-specific heap. (See Version Notes section.)

Return Value

A result code. See “Result Codes.”

Discussion

Your application should set the modeFlags parameter to kOSAModeNull. You can use the other parameters to specify memory sizes for the portion of your application’s heap used by the AppleScript component for its application-specific heap and stack. If your application sets any of these parameters to 0, the AppleScript component uses the corresponding value in your application’s 'scsz' resource. If that value is also set to 0, the AppleScript component uses the default values described in “Default Initialization Values.”

If your application doesn’t call ASInit explicitly, the AppleScript component initializes itself using the values specified in your application’s 'scsz' resource when your application first calls any scripting component routine. If any of these values are set to 0, the AppleScript component uses the corresponding default value.

If your application doesn’t call ASInit explicitly and doesn’t call any scripting component routines, the AppleScript component will not be initialized. For example, if your application opens and closes the AppleScript component or calls Component Manager functions such as OpenDefaultComponent or FindNextComponent but doesn’t call any scripting component routines, the AppleScript component is not initialized.

When the AppleScript component is initialized, it uses your application’s high memory to create the blocks that it locks for its own use. If you expect to lock any portion of high memory for a shorter time than you expect the AppleScript component to be available, you should call ASInit explicitly.

Version Notes

Starting in Mac OS X version 10.5, heap size parameter values are ignored—AppleScript's heap will grow as large as needed.

Availability
Declared In
AppleScript.h

ASSetHandler

Deprecated. Use OSASetHandler instead.

OSAError ASSetHandler (
   ComponentInstance scriptingComponent,
   OSAID contextID,
   const AEDesc *handlerName,
   OSAID compiledScriptID
);

Return Value

A result code. See “Result Codes.”

Version Notes

Provided for backward compatibility only. Use OSASetHandler instead.

Availability
Declared In
ASDebugging.h

ASSetProperty

Deprecated. Use OSASetProperty instead.

OSAError ASSetProperty (
   ComponentInstance scriptingComponent,
   OSAID contextID,
   const AEDesc *variableName,
   OSAID scriptValueID
);

Return Value

A result code. See “Result Codes.”

Version Notes

Provided for backward compatibility only. Use OSASetProperty instead.

Availability
Declared In
ASDebugging.h

ASSetSourceAttributes

Sets the text style attributes used by the AppleScript component to display scripts.

OSAError ASSetSourceAttributes (
   ComponentInstance scriptingComponent,
   CFArrayRef sourceAttributes
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

sourceAttributes

A reference to an array (of type CFArray) of dictionaries (of type CFDictionary) of text style attributes.

You can pass a nil reference for this parameter if you want the AppleScript component to display script text using its default styles.

Return Value

A result code. See “Result Codes.”

Discussion

A text style attribute is typically something that is meaningful to a CFAttributedString, such as the one returned by OSACopyDisplayString or OSACopySourceString. However, clients may add any attributes they like. Because of this, you should generally call ASSetSourceAttributes with a modified copy of the result from ASCopySourceAttributes, not a built-from-scratch set of attributes.

The order of elements in the array should correspond to the constants defined in “Source Style Constants,” and therefore also to the names returned by ASGetSourceStyleNames. After calling ASSetSourceAttributes, you must dispose of the style element array you used to specify the text style attributes.

Availability
Declared In
AppleScript.h

DisposeOSAActiveUPP

Disposes of a universal procedure pointer to an application-defined active function.

void DisposeOSAActiveUPP (
   OSAActiveUPP userUPP
);

Parameters
userUPP

The UPP to dispose of.

Availability
Declared In
OSA.h

DisposeOSACreateAppleEventUPP

Disposes of a universal procedure pointer to an application-defined Apple event create function.

void DisposeOSACreateAppleEventUPP (
   OSACreateAppleEventUPP userUPP
);

Parameters
userUPP

The UPP to dispose of.

Availability
Declared In
OSA.h

DisposeOSASendUPP

Disposes of a universal procedure pointer to an application-defined send function.

void DisposeOSASendUPP (
   OSASendUPP userUPP
);

Parameters
userUPP

The UPP to dispose of.

Availability
Declared In
OSA.h

InvokeOSAActiveUPP

Invokes an application-defined active function.

OSErr InvokeOSAActiveUPP (
   SRefCon refCon,
   OSAActiveUPP userUPP
);

Return Value

A result code. See “Result Codes.”

Availability
Declared In
OSA.h

InvokeOSACreateAppleEventUPP

Invokes an application-defined Apple event creation function.

OSErr InvokeOSACreateAppleEventUPP (
   AEEventClass theAEEventClass,
   AEEventID theAEEventID,
   const AEAddressDesc *target,
   short returnID,
   SInt32 transactionID,
   AppleEvent *result,
   SRefCon refCon,
   OSACreateAppleEventUPP userUPP
);

Return Value

A result code. See “Result Codes.”

Availability
Declared In
OSA.h

InvokeOSASendUPP

Invokes an application-defined send function.

OSErr InvokeOSASendUPP (
   const AppleEvent *theAppleEvent,
   AppleEvent *reply,
   AESendMode sendMode,
   AESendPriority sendPriority,
   SInt32 timeOutInTicks,
   AEIdleUPP idleProc,
   AEFilterUPP filterProc,
   SRefCon refCon,
   OSASendUPP userUPP
);

Return Value

A result code. See “Result Codes.”

Availability
Declared In
OSA.h

NewOSAActiveUPP

Creates a new universal procedure pointer to an application-defined active function.

OSAActiveUPP NewOSAActiveUPP (
   OSAActiveProcPtr userRoutine
);

Parameters
userRoutine

A pointer to the active function.

Return Value

The new UPP.

Availability
Declared In
OSA.h

NewOSACreateAppleEventUPP

Creates a new universal procedure pointer to an application-defined Apple event creation function.

OSACreateAppleEventUPP NewOSACreateAppleEventUPP (
   OSACreateAppleEventProcPtr userRoutine
);

Parameters
userRoutine

A pointer to the creation function.

Return Value

The new UPP.

Availability
Declared In
OSA.h

NewOSASendUPP

Creates a new universal procedure pointer to an application-defined send function.

OSASendUPP NewOSASendUPP (
   OSASendProcPtr userRoutine
);

Parameters
userRoutine

A pointer to the send function.

Return Value

The new UPP.

Availability
Declared In
OSA.h

OSAAddStorageType

Adds a trailer to the script data in a generic storage descriptor record.

OSErr OSAAddStorageType (
   AEDataStorage scriptData,
   DescType dscType
);

Parameters
scriptData

A handle to the script data.

dscType

The descriptor type to be specified in the trailer added to the script data.

Return Value

A result code. See “Result Codes.”

Discussion

The OSAAddStorageType function attaches a trailer to a handle (consequently expanding the data to which the handle refers) or updates an existing trailer.

Availability
Declared In
OSAComp.h

OSAAvailableDialectCodeList

Obtains a descriptor list containing dialect codes for each of a scripting component’s currently available dialects.

OSAError OSAAvailableDialectCodeList (
   ComponentInstance scriptingComponent,
   AEDesc *resultingDialectCodeList
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

resultingDialectCodeList

A pointer to the returned descriptor list.

Return Value

A result code. See “Result Codes.”

Discussion

Each item in the descriptor list returned by OSAAvailableDialectCodeList is a descriptor record of descriptor type typeInteger containing a dialect code for one of the specified scripting component’s currently available dialects. Dialect codes are defined by individual scripting components.

You can pass any dialect code you obtain using OSAAvailableDialectCodeList to OSAGetDialectInfo to get information about the corresponding dialect.

Availability
Declared In
OSA.h

OSAAvailableDialects

Obtains a descriptor list containing information about each of the currently available dialects for a scripting component.

OSAError OSAAvailableDialects (
   ComponentInstance scriptingComponent,
   AEDesc *resultingDialectInfoList
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

resultingDialectInfoList

A pointer to the returned descriptor list.

Return Value

A result code. See “Result Codes.”

Discussion

Each item in the list returned by OSAAvailableDialects is an AE record of descriptor type typeOSADialectInfo. Each descriptor record in the descriptor list contains, at a minimum, four keyword-specified descriptor records with the keywords described in “Dialect Descriptor Constants.”

Rather than calling OSAAvailableDialects to obtain complete dialect information for a scripting component, it is usually more convenient to call OSAAvailableDialectCodeList to get a list of codes for a scripting component’s dialects, then call OSAGetDialectInfo to get information about the specific dialect you’re interested in.

Availability
Declared In
OSA.h

OSACoerceFromDesc

Obtains the script ID for a script value that corresponds to the data in a descriptor record.

OSAError OSACoerceFromDesc (
   ComponentInstance scriptingComponent,
   const AEDesc *scriptData,
   SInt32 modeFlags,
   OSAID *resultingScriptID
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

scriptData

A pointer to a descriptor record containing the script data to be coerced.

modeFlags

Information used by individual scripting components. To avoid setting mode flag values, specify kOSAModeNull. If the scriptData parameter contains an Apple event, you can use any of the mode flags listed in “Mode Flags.”

resultingScriptValueID

A pointer to the resulting script ID for a script value. See the OSAID data type.

Return Value

A result code. See “Result Codes.”

Discussion

The OSACoerceFromDesc function coerces the descriptor record in the scriptData parameter to the equivalent script value and returns a script ID for that value.

If you pass OSACoerceFromDesc an Apple event in the scriptData parameter, it returns a script ID for the equivalent compiled script in the resultingScriptValueID parameter. In this case you can specify any of the modeFlags values used by OSACompile to control the way the compiled script is executed.

If you call OSACoerceFromDesc using an instance of the generic scripting component, the generic scripting component uses the default scripting component to perform the coercion.

Availability
Declared In
OSA.h

OSACoerceToDesc

Coerces a script value to a descriptor record of a desired descriptor type.

OSAError OSACoerceToDesc (
   ComponentInstance scriptingComponent,
   OSAID scriptID,
   DescType desiredType,
   SInt32 modeFlags,
   AEDesc *result
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

scriptID

The script ID for the script value to coerce. See the OSAID data type.

desiredType

The desired descriptor type of the resulting descriptor record.

modeFlags

Information used by individual scripting components. To avoid setting mode flag values, specify kOSAModeNull.

result

A pointer to the resulting descriptor record.

Return Value

A result code. See “Result Codes.”

Discussion

The OSACoerceToDesc function coerces the script value identified by scriptValueID to a descriptor record of the type specified by the desiredType parameter, if possible. Valid types include all the standard descriptor types, plus any special types supported by the scripting component.

If you want the descriptor type of the descriptor record returned in the result parameter to be the same as the descriptor type returned by a scripting component, use OSACoerceToDesc and specify typeWildCard as the desired type. If you want to get a script value in a form that you can display for humans to read, use OSADisplay.

Availability
Declared In
OSA.h

OSACompile

Compiles the source data for a script and obtain a script ID for a compiled script or a script context.

OSAError OSACompile (
   ComponentInstance scriptingComponent,
   const AEDesc *sourceData,
   SInt32 modeFlags,
   OSAID *previousAndResultingScriptID
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

sourceData

A pointer to a descriptor record containing suitable source data for the specified scripting component.

modeFlags

Information used by individual scripting components. To avoid setting mode flag values, specify kOSAModeNull. Other possible mode flags are listed in “Mode Flags.”

previousAndResultingScriptID

A pointer to the script ID for the resulting compiled script. If the value of this parameter on input is kOSANullScript, OSACompile returns a new script ID for the compiled script data. If the value of this parameter on input is an existing script ID, OSACompile updates the script ID so that it refers to the newly compiled script data. See the OSAID data type.

Return Value

A result code. See “Result Codes.”

Discussion

You can pass a descriptor record containing source data suitable for a specific scripting component (usually text) to the OSACompile function to obtain a script ID for the equivalent compiled script or script context. To compile the source data as a script context for use with OSAExecuteEvent or OSADoEvent, you must set the kOSAModeCompileIntoContext flag, and the source data should include appropriate handlers.

After you have successfully compiled the script, you can use the returned script ID to refer to the compiled script when you call OSAExecute and other scripting component routines.

If you use OSACompile with an instance of the generic scripting component and pass kOSANullScript in the previousAndResultingScriptID parameter, the generic scripting component uses the default scripting component to compile the script.

If you’re recompiling a script, specify the original script ID in the previousAndResultingScriptID parameter. The generic scripting component uses the script ID to determine which scripting component it should use to compile the script.

Availability
Declared In
OSA.h

OSACompileExecute

Compiles and executes a script in a single step rather than calling OSACompile and OSAExecute.

OSAError OSACompileExecute (
   ComponentInstance scriptingComponent,
   const AEDesc *sourceData,
   OSAID contextID,
   SInt32 modeFlags,
   OSAID *resultingScriptValueID
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

sourceData

A pointer to a descriptor record identifying suitable source data for the specified scripting component.

contextID

The script ID for the context to be used during script execution. The constant kOSANullScript in this parameter indicates that the scripting component should use its default context. See the OSAID data type.

modeFlags

Information used by individual scripting components. To avoid setting mode flag values, specify kOSAModeNull. Other possible mode flags are listed in “Mode Flags.”

resultingScriptValueID

A pointer to the script ID for the script value returned.

Return Value

A result code. See “Result Codes.”

Discussion

The OSACompileExecute function compiles source data and executes the resulting compiled script, using the script context identified by the contextID parameter to maintain state information such as the binding of variables. After successfully executing the script, OSACompileExecute disposes of the compiled script and returns either the script ID for the resulting script value or, if execution does not result in a value, the constant kOSANullScript.

If the result c ode returned by OSACompileExecute is a general result code, there was some problem in arranging for the script to be run. If the result code is errOSAScriptError, an error occurred during script execution. In this case, you can obtain more detailed error information by calling OSAScriptError.

Availability
Declared In
OSA.h

OSACopyDisplayString

Converts a script value to an attributed Unicode text string, which your application can display to the user.

OSAError OSACopyDisplayString (
   ComponentInstance scriptingComponent,
   OSAID scriptID,
   SInt32 modeFlags,
   CFAttributedStringRef *result
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

scriptID

The script ID for the script value to display. See the OSAID data type.

modeFlags

Information used by individual scripting components. To avoid setting any mode flags, specify kOSAModeNull. To make the resulting text readable by humans only, so that it can’t be recompiled, specify kOSAModeDisplayForHumans.

result

If successful, a reference to the script data as an attributed Unicode text string; otherwise not defined.

Because the result parameter returns a copy, the caller is responsible for releasing this string object, according to the rules described in Ownership Policy in Memory Management Programming Guide for Core Foundation.

Return Value

A result code. See “Result Codes.”

Discussion

The OSACopyDisplayString function is analogous to OSADisplay, except that it returns the script text as an attributed Unicode text string. An instance of CFAttributedString manages a character string and an associated set of attributes that apply to characters or ranges of characters in the string. You can call ASCopySourceAttributes to get the current AppleScript source style attributes.

Availability
Declared In
OSA.h

OSACopyID

Updates script data after editing or recording and to perform undo or revert operations on script data.

OSAError OSACopyID (
   ComponentInstance scriptingComponent,
   OSAID fromID,
   OSAID *toID
);

Parameters
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent.

fromID

The script ID for script data that you want to be associated with the script ID in the toID parameter. See the OSAID data type.

toID

A pointer to the script ID for the script data to be replaced. If the value of this parameter is kOSANullScript, the OSACopyID function returns a new script ID. See the OSAID data type.

Return Value

A result code. See “Result Codes.”

Discussion

The OSACopyID function replaces the script data identified by the script ID in the toID parameter with the script data identified by the script ID in the fromID parameter.

Availability
Declared In
OSA.h

OSACopyScriptingDefinition

Creates a copy of a scripting definition (sdef) from the specified file or bundle.

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

Parameters
ref

A file reference to the application file or bundle