Important: The information in this document is obsolete and should not be used for new development.
Get1Resource
You can use theGet1Resourcefunction to get resource data for a resource in the current resource file.
FUNCTION Get1Resource (theType: ResType; theID: Integer): Handle;
theType- A resource type.
theID- An integer that uniquely identifies a resource of the specified type.
DESCRIPTION
TheGet1Resourcefunction searches the current resource file's resource map in memory for the resource specified by thetheTypeandtheIDparameters. IfGet1Resourcefinds an entry for the resource in the current resource file's resource map and the entry contains a valid handle, it returns that handle. If the entry contains a handle whose value isNIL, and if you haven't calledSetResLoadwith theloadparameter set toFALSE,Get1Resourceattempts to read the resource into memory.If
Get1Resourcecan't find the resource data, it returnsNIL, andResErrorreturns the result coderesNotFound. TheGet1Resourcefunction also returnsNILif the resource data to be read into memory won't fit, in which caseResErrorreturns an appropriate Memory Manager result code.If you call
Get1Resourcewith a resource type that can't be found in the resource map of the current resource file, the function returnsNIL, butResErrorreturns the result codenoErr. You should always check that the value of the returned handle is notNIL.You can change the resource map search order by calling the
UseResFileprocedure beforeGet1Resource.SPECIAL CONSIDERATIONS
CallingGet1Resourcemay move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.RESULT CODES
noErr 0 No error resNotFound -192 Resource not found SEE ALSO
To check for errors, call theResErrorfunction as described on page 1-47.For examples of the use of the
Get1Resourcefunction, see Listing 1-8 on page 1-23 and Listing 1-9 on page 1-26.To include ROM-resident system resources in the Resource Manager's search of the resource maps for open resource forks, use the
RGetResourcefunction as described on page 1-73.For information about the
UseResFileandSetResLoadprocedures, see page 1-65 and page 1-74, respectively.