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
Required Scripting Component Routines / Setting and Getting Script Information


OSAGetScriptInfo

You can use OSAGetScriptInfo to obtain information about script data according to the value you pass in the selector parameter.

FUNCTION OSAGetScriptInfo(scriptingComponent: ComponentInstance;
                          scriptID: OSAID; 
                          selector: OSType; 
                          VAR result: LongInt): OSAError;
scriptingComponent
A component instance created by a prior call to the Component Manager function OpenDefaultComponent or OpenComponent (see page 10-4).
scriptID
The script ID for the script data about which to obtain information.
selector
A value that determines what kind of information OSAGetScriptInfo returns. The value can be one of these constants:
            CONST kOSAScriptIsModified             = 'modi'; 
                  kOSAScriptIsTypeCompiledScript   = 'cscr'; 
                  kOSAScriptIsTypeScriptValue      = 'valu'; 
                  kOSAScriptIsTypeScriptContext    = 'cntx'; 
                  kOSAScriptBestType               = 'best'; 
                  kOSACanGetSource                 = 'gsrc'; 
The AppleScript component provides limited support for the constant kOSAScriptIsModified (see page 10-44). In addition to the standard constants, the AppleScript component also supports this constant:
            CONST kASHasOpenHandler          = 'hsod'; 
result
The requested information, which you can coerce to the appropriate descriptor type for the value specified in the selector parameter.
DESCRIPTION
The OSAGetScriptInfo function returns various results according to the value you pass in the selector parameter.
Value of selector parameterInformation returned in the result parameter
kOSAScriptIsModifiedLong integer that indicates the number of times the script data has been modified since it was passed to OSALoad.
kOSAScriptIsTypeCompiledScriptBoolean value that indicates whether or not the script data is a compiled script.
  
kOSAScriptIsTypeScriptValueBoolean value that indicates whether or not the script data is a script value.
kOSAScriptIsTypeScriptContextBoolean value that indicates whether or not the script data is a script context.
kOSAScriptBestTypeA descriptor type that you can pass to OSACoerceToDesc.
kOSACanGetSourceBoolean value that indicates whether the script data can be successfully passed to OSAGetSource.

The AppleScript component also provides this constant for use in the selector parameter.
Value of selector parameterInformation returned in the result parameter
kASHasOpenHandlerBoolean value that indicates whether a script context with the specified script ID contains a handler for the Open Documents event. If the script ID doesn't identify a script context, OSAGetScriptInfo returns the result code errOSAIllegalAccess.

SPECIAL CONSIDERATIONS
Although you can specify kOSAScriptIsModified when you are using the AppleScript component without generating an error, the current version of AppleScript interprets this request conservatively. The AppleScript component stores script data in a network of interlocking structures, and running a script can cause any of these structures to be modified. If you pass a script ID is to OSAGetScriptInfo with kOSAScriptIsModified as the value of the selector parameter, the AppleScript component returns 1 if there is any possibility that the script data or related structures may have been modified, and 0 if there is no possibility that they have been modified.

RESULT CODES
noErr0No error
errOSASystemError-1750General scripting system error
errOSAInvalidID-1751Invalid script ID
errOSABadSelector-1754Selector value not supported by scripting component
badComponentInstance$80008001Invalid component instance

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996