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 / Executing Scripts in One Step


OSALoadExecute

You can use the OSALoadExecute function to load and execute a script in a single step rather than calling OSALoad and OSAExecute.

FUNCTION OSALoadExecute (scriptingComponent: ComponentInstance;
                         scriptData: AEDesc; 
                         contextID: OSAID; 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
The descriptor record identifying the script data to be loaded and executed.
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
The OSALoadExecute function loads script data and executes the resulting compiled script, using the script context identified by the contextID parameter to maintain state information such as the binding of variables. After successfully executing the script, OSALoadExecute 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 constant kOSANullScript.

You can control the way in which the scripting component executes a script by adding any of these flags to the modeFlags parameter:
FlagDescription
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.
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).
kOSAModeDontReconnectAdds kAEDontReconnect to sendMode parameter of AESend for events sent when script is executed.
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).

If the result code returned by OSALoadExecute is a general result code, there was some problem in arranging for the script to be run. If the result code is errOSAScriptError, an error occurred during script execution. In this case, you can obtain more detailed error information by calling OSAScriptError.

RESULT CODES
noErr0No error
errOSACorruptData-1702Same as errAECorruptData
errOSASystemError-1750General scripting system error
errOSAInvalidID-1751Invalid script ID
errOSABadStorageType-1752Script data not for this scripting component
errOSAScriptError-1753Error occurred during execution
errOSADataFormatObsolete-1758Data format is obsolete
errOSADataFormatTooNew-1759Data format is too new
badComponentInstance$80008001Invalid component instance

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996