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
Optional Scripting Component Routines / Coercing Script Values


OSACoerceFromDesc

You can use the OSACoerceFromDesc 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 or OpenComponent (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 the scriptData 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
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:
FlagDescription
kOSAModePreventGetSourceCompiled script consists of only the minimum script data required to run the script. It will cause an error if passed to OSAGetSource.
kOSACompileIntoContextThe OSACoerceFromDesc function returns a script context instead of a compiled script.
kOSAModeNeverInteractAdds kAENeverInteract to sendMode parameter of AESend for events sent when script is executed.
kOSAModeCanInteractAdds kAECanInteract to sendMode parameter of AESend for events sent when script is executed.
kOSAModeAlwaysInteractAdds kAEAlwaysInteract to sendMode parameter of AESend for events sent when script is executed.
kOSAModeDontReconnectAdds kAEDontReconnect to sendMode parameter of AESend for events sent when script is executed.
kOSAModeCantSwitchLayerPrevents use of kAECanSwitchLayer in sendMode parameter of AESend for events sent when script is executed (the opposite of the Apple Event Manager's interpretation of the same bit).
kOSAModeDoRecordPrevents use of kAEDontRecord in sendMode parameter of AESend for events sent when script is executed (the opposite of the Apple Event Manager's interpretation of the same bit).

SPECIAL CONSIDERATIONS
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.

RESULT CODES
noErr0No error
errOSASystemError-1750General scripting system error
badComponentInstance$80008001Invalid 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.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996