Important: The information in this document is obsolete and should not be used for new development.
OSACompile
You can use theOSACompile
function to compile the source data for a script and obtain a script ID for a compiled script or a script context.
FUNCTION OSACompile (scriptingComponent: ComponentInstance; sourceData: AEDesc; modeFlags: LongInt; VAR previousAndResultingScriptID: OSAID) : OSAError;
scriptingComponent
- A component instance created by a prior call to the Component Manager function
OpenDefaultComponent
orOpenComponent
(see page 10-4).sourceData
- A descriptor record containing suitable source data for the specified scripting component.
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.previousAndResulting
ScriptID
- The script ID for the resulting compiled script. If the value of this parameter on input is
kOSANullScript
,OSACompile
returns a new script ID for the compiled script data. If the value of this parameter on input is an existing script ID,OSACompile
updates the script ID so that it refers to the newly compiled script data.DESCRIPTION
You can pass a descriptor record containing source data suitable for a specific scripting component (usually text) to theOSACompile
function to obtain a script ID for the equivalent compiled script or script context. To compile the source data as a script context for use withOSAExecuteEvent
orOSADoEvent
, you must set thekOSACompileIntoContext
flag, and the source data should include appropriate handlers.After you have successfully compiled the script, you can use the returned script ID to refer to the compiled script when you call
OSAExecute
and other scripting component routines.You can control the way a compiled script is executed by adding any of these flags to the
modeFlags
parameter:
Flag Description kOSAModePreventGetSource Compiled script consists of only the minimum script data required to run the script. It will cause an error if passed to OSAGetSource
.kOSACompileIntoContext The OSACompile
function returns a script context instead of a compiled script.kOSAModeAugmentContext Script data associated with script ID passed in previousAndResulting
CompiledScriptID
is augmented rather than replaced with the new compiled script. Specifying this flag automatically invokes thekOSAModeCompileIntoContext
mode flag. If you redefine variables, handlers, and so on that were previously defined in the script context, the new definitions will replace the old ones.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.kOSAModeDontReconnect Adds kAEDontReconnect
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).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).SPECIAL CONSIDERATIONS
If you useOSACompile
with an instance of the generic scripting component and passkOSANullScript
in thepreviousAndResulting
ScriptID
parameter, the generic scripting component uses the default scripting component to compile the script.If you're recompiling a script, specify the original script ID in the
previousAndResultingScriptID
parameter. The generic scripting component uses the script ID to determine which scripting component it should use to compile the script.RESULT CODES
SEE ALSO
For an example of the use ofOSACompile
to update an existing script ID, see Listing 10-5 on page 10-18. For an example of the use ofOSACompile
to obtain a new script ID, see Listing 10-2 on page 10-9.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.