Important: The information in this document is obsolete and should not be used for new development.
OSACompileExecute
You can use theOSACompileExecute
routine to compile and execute a script in a single step rather than callingOSACompile
andOSAExecute
.
FUNCTION OSACompileExecute (scriptingComponent: ComponentInstance; sourceData: AEDesc; contextID: OSAID; modeFlags: LongInt; VAR resultingScriptValueID: OSAID): OSAError;
scriptingComponent
A component instance created by a prior call to the Component Manager functionOpenDefaultComponent
orOpenComponent
(see page 10-4).- sourceData
- A descriptor record identifying suitable source data for the specified scripting component.
contextID
- The script ID for the context to be used during script execution. The constant
kOSANullScript
in 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
TheOSACompileExecute
function compiles source data and executes the resulting compiled script, using the script context identified by thecontextID
parameter to maintain state information such as the binding of variables. After successfully executing the script,OSACompileExecute
disposes of the compiled script and returns either the script ID for the resulting script value or, if execution does not result in a value, the constantkOSANullScript
.You can control the way in which the scripting component executes a script by adding any of these flags to the
modeFlags
parameter:
Flag Description 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.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).kOSAModeDontReconnect Adds kAEDontReconnect
tosendMode
parameter ofAESend
for events sent when script is executed.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).If the result code returned by
OSACompileExecute
is 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