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


OSADoScript

You can use the OSADoScript routine to compile and execute a script and convert the resulting script value to text in a single step rather than calling OSACompile, OSAExecute, and OSADisplay.

FUNCTION OSADoScript (scriptingComponent: ComponentInstance;
                      sourceData: AEDesc; 
                      contextID: OSAID; desiredType: DescType; 
                      modeFlags: LongInt; 
                      VAR resultingText: AEDesc): OSAError;
scriptingComponent

A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent (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.
desiredType
The desired text descriptor type, such as typeChar, for the resulting descriptor record.
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.
resultingText
The resulting descriptor record.
DESCRIPTION
Calling the OSADoScript function is equivalent to calling OSACompile followed by OSAExecute and OSADisplay. After compiling the source data, executing the compiled script using the script context identified by the contextID parameter, and returning the text equivalent of the resulting script value in the resultingText parameter, OSADoScript disposes of both the compiled script and the resulting script value.

You can control the way in which the scripting component executes the 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).
kOSAModeDisplayForHumansResulting text is readable by humans only and cannot be recompiled by OSACompile.

If the result code returned by OSADoScript 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, and the resultingText parameter contains the error message associated with the error. In this case, you can obtain more detailed error information by calling OSAScriptError.

RESULT CODES
noErr0No error
errOSACantCoerce-1700Data could not be coerced to the requested data type
errOSASystemError-1750General scripting system error
errOSAInvalidID-1751Invalid script ID
errOSAScriptError-1753Source data invalid (syntax error) or an execution error occurred
badComponentInstance$80008001Invalid component instance
SEE ALSO
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.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996