Important: The information in this document is obsolete and should not be used for new development.
OSACoerceFromDesc
You can use theOSACoerceFromDescfunction to obtain the script ID for a script value that corresponds to the data in a descriptor record.
FUNCTION OSACoerceFromDesc (scriptingComponent: ComponentInstance; scriptData: AEDesc; modeFlags: LongInt; VAR resultingScriptValueID: OSAID): OSAError;
scriptingComponent- A component instance created by a prior call to the Component Manager function
OpenDefaultComponentorOpenComponent(see page 10-4).scriptData- 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 thescriptDataparameter contains an Apple event, you can use any of the mode flags listed in the description that follows.resultingScriptValueID- The resulting script ID for a script value.
DESCRIPTION
TheOSACoerceFromDescfunction coerces the descriptor record in thescriptDataparameter to the equivalent script value and returns a script ID for that value.If you pass
OSACoerceFromDescan Apple event in thescriptDataparameter, it returns a script ID for the equivalent compiled script in theresultingScriptValueIDparameter. In this case you can specify any of themodeFlagsvalues used byOSACompileto control the way the compiled script is executed:
Flag Description kOSAModePreventGetSource Compiled script consists of only the minimum script data required to run the script. It will cause an error if passed to OSAGetSource.kOSACompileIntoContext The OSACoerceFromDescfunction returns a script context instead of a compiled script.kOSAModeNeverInteract Adds kAENeverInteracttosendModeparameter ofAESendfor events sent when script is executed.kOSAModeCanInteract Adds kAECanInteracttosendModeparameter ofAESendfor events sent when script is executed.kOSAModeAlwaysInteract Adds kAEAlwaysInteracttosendModeparameter ofAESendfor events sent when script is executed.kOSAModeDontReconnect Adds kAEDontReconnecttosendModeparameter ofAESendfor events sent when script is executed.kOSAModeCantSwitchLayer Prevents use of kAECanSwitchLayerinsendModeparameter ofAESendfor events sent when script is executed (the opposite of the Apple Event Manager's interpretation of the same bit).kOSAModeDoRecord Prevents use of kAEDontRecordinsendModeparameter ofAESendfor events sent when script is executed (the opposite of the Apple Event Manager's interpretation of the same bit).SPECIAL CONSIDERATIONS
If you callOSACoerceFromDescusing an instance of the generic scripting component, the generic scripting component uses the default scripting component to perform the coercion.RESULT CODES
noErr 0 No error errOSASystemError -1750 General scripting system error badComponentInstance $80008001 Invalid component instance SEE ALSO
For more information about the default scripting component associated with any instance of the generic scripting component, see "Generic Scripting Component Routines," which begins on page 10-83.