Important: The information in this document is obsolete and should not be used for new development.
OSAExecute
You can use theOSAExecutefunction to execute a compiled script or a script context.
FUNCTION OSAExecute(scriptingComponent: ComponentInstance; compiledScriptID: OSAID; contextID: OSAID; 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).compiledScriptID- The script ID for the compiled script to be executed.
contextID- The script ID for the context to be used during script execution. The constant
kOSANullScriptin this parameter indicates that the scripting component should use its default context.modeFlags- Information used by individual scripting components. To avoid setting mode flag values, specify
kOSAModeNull. Other possible mode flags are listed in the description that follows.resultingScriptValueID- The script ID for the script value returned.
DESCRIPTION
TheOSAExecutefunction executes the compiled script identified by thecompiledScriptIDparameter, using the script context identified by thecontextIDparameter to maintain state information, such as the binding of variables, for the compiled script. After successfully executing a script,OSAExecutereturns the script ID for a resulting script value, or, if execution does not result in a value, the constantkOSANullScript.You can use the
OSACoerceToDescfunction to coerce the resulting script value to a descriptor record of a desired descriptor type, or theOSADisplayfunction to obtain the equivalent source data for the script value.You can control the way in which the scripting component executes a script by adding any of these flags to the
modeFlagsparameter:
Flag Description 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.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).kOSAModeDontReconnect Adds kAEDontReconnecttosendModeparameter ofAESendfor events sent when script is executed.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).If the result code returned by
OSAExecuteis a general result code, there was some problem in arranging for the script to be run. If the result code iserrOSAScriptError, an error occurred during script execution. In this case, you can obtain more detailed error information by callingOSAScriptError.RESULT CODES
SEE ALSO
For information about theOSAGetSourceandOSACoerceToDescfunctions, see page 10-51 and page 10-54, respectively.For examples of the use of the
OSAExecutefunction, see Listing 10-2 on page 10-9 and Listing 10-4 on page 10-16.For more information about resume dispatch functions, see "Supplying a Resume Dispatch Function," which begins on page 10-21, and the description of a resume dispatch function on page 10-95.