Important: The information in this document is obsolete and should not be used for new development.
UseResFile
You can use theUseResFileprocedure to set the current resource file.
PROCEDURE UseResFile (refNum: Integer);
refNum- The file reference number for a resource fork.
DESCRIPTION
TheUseResFileprocedure searches the list of files whose resource forks have been opened for the file specified by therefNumparameter. If the specified file is found, the Resource Manager sets the current resource file to the specified file. If there's no resource fork open for a file with that reference number,UseResFiledoes nothing. To set the current resource file to the System file, use 0 for therefNumparameter.Open resource forks are arranged as a linked list with the most recently opened resource fork at the beginning. When searching open resource forks, the Resource Manager starts with the most recently opened file. You can call the
UseResFileprocedure to set the current resource file to a file opened earlier, and thereby start subsequent searches with the specified file. In this way, you can cause any files higher in the resource chain to be left out of subsequent searches.When a new resource fork is opened, this action overrides previous calls to
UseResFileand the entire list is searched. For example, if five resource forks are opened in the order R0, R1, R2, R3, and R4, the search order is R4-R3-R2-R1-R0. CallingUseResFile(R2)changes the search order to R2-R1-R0; R4 and R3 are not searched. When the resource fork of a new file (R5) is opened, the search order becomes R5-R4-R3-R2-R1-R0.You typically call
CurResFileto get and save the current resource file,UseResFileto set the current resource file to the desired file, then (after you are finished using the resource)UseResFileto restore the current resource file to its previous value. CallingUseResFile(0)causes the Resource Manager to search only the System file's resource map. This is useful if you no longer wish to override a system resource with one by the same name in your application's resource fork.SPECIAL CONSIDERATIONS
TheFSpOpenResFile,HOpenResFile, andOpenResFilefunctions, which also set the current resource file, override previous calls toUseResFile.ASSEMBLY-LANGUAGE INFORMATION
The settings of the system global variablesRomMapInsertandTmpResLoadaffect resource search order. These global variables determine whether the Resource Manager searches ROM-resident resources before the System file's resources.The Resource Manager normally searches ROM resources only when you use the
RGetResourcefunction to get a handle to the resource, and even then only after it searches the System file's resource fork. To search for a resource in ROM before searching the System file's resource fork, your application must first alter the resource search order by inserting the ROM resource map in front of the System file's resource map.When the value of the system global variable
RomMapInsertisTRUE, the Resource Manager inserts the ROM resource map before the System file's resource map for the next call only (including any Resource Manager routine that gets a resource, not justRGetResource). When the value ofRomMapInsertisTRUE, the adjacent variableTmpResLoaddetermines whether the value of the global variableResLoadis consideredTRUEorFALSE, overriding the actual value ofResLoadfor the next call only. The values of theRomMapInsertandTmpResLoadvariables are cleared after each call to a Resource Manager routine.You can use two global constants to set these variables in tandem. Set the system global variable
RomMapInsertto the global constantmapTrueto insert the ROM resource map withSetResLoad(TRUE). Set the system global variableRomMapInsertto the global constantmapFalseto insert the ROM resource map withSetResLoad(FALSE).RESULT CODES
noErr 0 No error resFNotFound -193 Resource file not found SEE ALSO
To check for errors, call theResErrorfunction as described on page 1-47.For an example of the use of the
UseResFileprocedure, see Listing 1-8 on page 1-23.For descriptions of the
FSpOpenResFile,HOpenResFile, andOpenResFilefunctions, see page 1-54 through page 1-62. For a description of theSetResLoadprocedure, see page 1-74.