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 / Getting Source Data


OSAGetSource

You can use the OSAGetSource function to decompile the script data identified by a script ID and obtain the equivalent source data.

FUNCTION OSAGetSource(scriptingComponent: ComponentInstance;
                      scriptID: OSAID; 
                      desiredType: DescType;
                      VAR resultingSourceData: AEDesc): 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 to decompile. If you pass kOSANullScript in this parameter, OSAGetSource returns a null source description (such as an empty text string).
desiredType
The desired descriptor type of the resulting descriptor record, or typeBest if any type will do.
resultingSourceData
The resulting descriptor record.
DESCRIPTION
The OSAGetSource function decompiles the script data identified by the specified script ID and returns a descriptor record containing the equivalent source data. The source data returned need not be exactly the same as the source data originally passed to OSACompile--for example, white space and formatting might be different--but it should be a reasonable equivalent suitable for user viewing and editing.

The difference between OSACoerceToDesc and OSAGetSource is that OSAGetSource creates source data that can be displayed to a user or compiled and executed to generate an appropriate value, whereas OSACoerceToDesc actually returns the value. For example, if you call OSAGetSource and specify a string value, it returns the text surrounded by quotation marks (so that it can be properly compiled). If you call OSACoerceToDesc and specify a string value, it simply returns the text.

The main difference between OSADisplay and OSAGetSource is that OSAGetSource can coerce any form of script data using a variety of descriptor types, whereas OSADisplay can coerce only script values and always produces a descriptor record of a text descriptor type.

RESULT CODES
noErr0No error
errOSASystemError-1750General scripting system error
errOSAInvalidID-1751Invalid script ID
errOSASourceNotAvailable-1756Source data not available
badComponentInstance$80008001Invalid component instance
SEE ALSO
For an example of the use of OSAGetSource, see Listing 10-5 on page 10-18.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996