UseResFileYou can use the
UseResFileprocedure to set the current resource file.
PROCEDURE UseResFile (refNum: Integer);
- The file reference number for a resource fork.
UseResFileprocedure searches the list of files whose resource forks have been opened for the file specified by the
refNumparameter. 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 the
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. Calling
UseResFile(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. Calling
UseResFile(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.
OpenResFilefunctions, which also set the current resource file, override previous calls to
ASSEMBLY-LANGUAGE INFORMATIONThe settings of the system global variables
TmpResLoadaffect 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
TRUE, 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 just
RGetResource). When the value of
TRUE, the adjacent variable
TmpResLoaddetermines whether the value of the global variable
FALSE, overriding the actual value of
ResLoadfor the next call only. The values of the
TmpResLoadvariables 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 constant
mapTrueto insert the ROM resource map with
SetResLoad(TRUE). Set the system global variable
RomMapInsertto the global constant
mapFalseto insert the ROM resource map with
noErr 0 No error resFNotFound -193 Resource file not found
SEE ALSOTo check for errors, call the
ResErrorfunction 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
OpenResFilefunctions, see page 1-54 through page 1-62. For a description of the
SetResLoadprocedure, see page 1-74.