Important: The information in this document is obsolete and should not be used for new development.
OSAStore
You can use theOSAStore
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
orOpenComponent
(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, passkOSAModePreventGetSource
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 thescriptID
parameter identifies a script context, you can passkOSAModeDontStoreParent
in this parameter to store the script context without storing its parent context.resultingScriptData
- The resulting descriptor record.
DESCRIPTION
TheOSAStore
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 toOSALoad
.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 themodeFlags
parameter. If thescriptID
parameter identifies a script context and you don't want the returned script data to include the associated parent context, specify thekOSAModeDontStoreParent
flag in themodeFlags
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
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.