Important: The information in this document is obsolete and should not be used for new development.
OSACoerceFromDesc
You can use theOSACoerceFromDesc
function 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
OpenDefaultComponent
orOpenComponent
(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 thescriptData
parameter 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
TheOSACoerceFromDesc
function coerces the descriptor record in thescriptData
parameter to the equivalent script value and returns a script ID for that value.If you pass
OSACoerceFromDesc
an Apple event in thescriptData
parameter, it returns a script ID for the equivalent compiled script in theresultingScriptValueID
parameter. In this case you can specify any of themodeFlags
values used byOSACompile
to 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 OSACoerceFromDesc
function returns a script context instead of a compiled script.kOSAModeNeverInteract Adds kAENeverInteract
tosendMode
parameter ofAESend
for events sent when script is executed.kOSAModeCanInteract Adds kAECanInteract
tosendMode
parameter ofAESend
for events sent when script is executed.kOSAModeAlwaysInteract Adds kAEAlwaysInteract
tosendMode
parameter ofAESend
for events sent when script is executed.kOSAModeDontReconnect Adds kAEDontReconnect
tosendMode
parameter ofAESend
for events sent when script is executed.kOSAModeCantSwitchLayer Prevents use of kAECanSwitchLayer
insendMode
parameter ofAESend
for events sent when script is executed (the opposite of the Apple Event Manager's interpretation of the same bit).kOSAModeDoRecord Prevents use of kAEDontRecord
insendMode
parameter ofAESend
for events sent when script is executed (the opposite of the Apple Event Manager's interpretation of the same bit).SPECIAL CONSIDERATIONS
If you callOSACoerceFromDesc
using 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.