Important: The information in this document is obsolete and should not be used for new development.
Get1IndResource
You can use theGet1IndResourcefunction repeatedly to get handles to all resources of a given type in the current resource file.
FUNCTION Get1IndResource (theType: ResType; index: Integer): Handle;
theType- A resource type.
index- An integer ranging from 1 to the number of resources of a given type returned by
Count1Resources, which is the number of resource types in the current resource file.DESCRIPTION
Given an index ranging from 1 to the number of resources of a given type returned byCount1Resources(that is, the number of resources of that type in the current resource file), theGet1IndResourcefunction returns a handle to a resource of the given type. If you callGet1IndResourcerepeatedly over the entire range of the index, it returns handles to all resources of the given type in the current resource file.The function reads the resource data into memory if it's not already there, unless you've called
SetResLoadwith theloadparameter set toFALSE.
If you provide an index to
- IMPORTANT
- If you've called
SetResLoadwith theloadparameter set toFALSEand the data isn't already in memory,Get1IndResourcereturns an empty handle (that is, a handle whose master pointer is set toNIL). This can also happen if you read resource data for a purgeable resource into memory and then callSetResLoadwith theloadparameter set toFALSE. If the resource data is later purged and you call theGet1IndResourcefunction,Get1IndResourcereturns an empty handle. You should test for an empty handle in these situations. To make the handle a valid handle to resource data in memory, you can call theLoadResourceprocedure.![]()
Get1IndResourcethat's either 0 or negative,Get1IndResourcereturnsNIL, and theResErrorfunction returns the result coderesNotFound. If the given index is larger than the value returned byCount1Resources,Get1IndResourcereturnsNIL, andResErrorreturns the result coderesNotFound. If the resource to be read won't fit into memory,Get1IndResourcereturnsNIL, andResErrorreturns the appropriate result code.SPECIAL CONSIDERATIONS
TheGet1IndResourcefunction may 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 an example of the use of the
Get1IndResourcefunction, see Listing 1-10 on page 1-28.For a description of the
Count1Resourcesfunction, see page 1-93. For a description of theUseResFileprocedure, see page 1-65. For descriptions of theSetResLoadandLoadResourceprocedures, see page 1-74 and page 1-75, respectively.