Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Interapplication Communication /
Chapter 10 - Scripting Components / Scripting Components Reference
Required Scripting Component Routines / Saving and Loading Script Data


OSAStore

You can use the OSAStore function to get a handle to script data in the form of a storage descriptor record.

FUNCTION OSAStore(scriptingComponent: ComponentInstance; 
                  scriptID: OSAID; 
                  desiredType: DescType;
                  modeFlags: LongInt;
                  VAR resultingScriptData: AEDesc): OSAError;
scriptingComponent
A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent (see page 10-4).
scriptID
The script ID for the script data for which to obtain a data handle.
desiredType
The desired type of the descriptor record to be returned. If you want to store the script data in the form used by a generic storage descriptor record, specify typeOSAGenericStorage.
modeFlags
Information used by individual scripting components. To avoid setting any mode flags, specify kOSAModeNull. To indicate that only the minimum script data required to run the script should be returned, pass kOSAModePreventGetSource in this parameter. (In this case the script data returned is not identical to the compiled script data and can't be used to generate source data.) If the scriptID parameter identifies a script context, you can pass kOSAModeDontStoreParent in this parameter to store the script context without storing its parent context.
resultingScriptData
The resulting descriptor record.
DESCRIPTION
The OSAStore function writes script data to a descriptor record so that the data can later be saved in a resource or written to the data fork of a document. You can then reload the data for the descriptor record as a compiled script (although possibly with a different script ID) by passing the descriptor record to OSALoad.

If you want the returned script data to be as small as possible and you are sure that you won't need to display the source data to the user, specify the kOSAModePreventGetSource flag in the modeFlags parameter. If the scriptID parameter identifies a script context and you don't want the returned script data to include the associated parent context, specify the kOSAModeDontStoreParent flag in the modeFlags parameter.

The desired type is either typeOSAGenericStorage (for a generic storage descriptor record) or a specific scripting component subtype value (for a component-specific storage descriptor record).

To store either a generic storage descriptor record or a component-specific storage descriptor record with your application's resources, use 'scpt' as the resource type. The generic scripting component subtype, the generic storage descriptor type, and the resource type for stored script data all have the same value, though they serve different purposes.

CONST 
   kOSAGenericScriptingComponentSubtype = 'scpt';
   kOSAScriptResourceType = kOSAGenericScriptingComponentSubtype;
   typeOSAGenericStorage = kOSAScriptResourceType;
RESULT CODES
noErr0No error
errOSASystemError-1750General scripting system error
errOSAInvalidID-1751Invalid script ID
errOSABadStorageType-1752Desired type not supported by this scripting component
badComponentInstance$80008001Invalid component instance
SEE ALSO
For more information about storage formats for script data, see "Saving Script Data" on page 10-12.

For an example of the use of OSAStore, see Listing 10-6 on page 10-19.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996