Path: utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: What is OpenRFPerm doing?!? Keywords: help resource file Message-ID: <7017@hoptoad.uucp> Date: 16 Apr 89 19:07:50 GMT References: <1146@uvm-gen.UUCP> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Distribution: na Organization: Eclectic Software, San Francisco Lines: 41 In article <1146@uvm-gen.UUCP> chaffee@uvm-gen.UUCP (Alex D. Chaffee) writes: >Help! All I did was open a resource file with the following call > OpenRFPerm(fName, vRefNum, (SignedByte)fsRdWrPerm); >and my resources got mangled. After the call, my Alerts show all the >signs of being handles to nowhere (i.e. they seem to be appearing off-screen, >they beep occasionally...). >fName and vRefNum come straight from SFGetFile's reply record, and there >are no ALRTs in the file I opened... Can anybody remember when _they_ >were inexperienced and ran into something like this? I don't remember running into anything like this. However, one explanation that springs to mind and seems to fit the facts is that you opened a corrupt resource file. Having a corrupt file as the first file in the list could easily perturb all resource searches. One way to check this would be to open it, then UseResFile on your application file to take the newly opened file out of the picture. If things then work OK, my guess would be fairly well confirmed. Another way, if you're using MPW, would be to use RezDet on the file that causes the problems. Other useful debugging information would come from opening a variety of files and seeing if they all cause the same symptoms; if so, the problem is in your code somewhere. You'll find that if you post code, there's no lack of people here able and willing to find flaws in it.... One final idea: the resource file you opened may include DITLs that conflict with yours even though there are no ALRTs. In general, it is not at all safe to open other resource files and leave them open as you're running, since your code depends on seeing resources that look a certain way with a certain number. The potential for conflicts is enormous. If you must open other resource files that are not owned by you, don't leave them open in the resource search path. Either UseResFile to take them out of the picture, or close them as soon as you're done and before going back to your main event loop. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "The pride of the peacock is the glory of God. The lust of the goat is the bounty of God. The wrath of the lion is the wisdom of God. The nakedness of woman is the work of God." - Blake, "The Marriage of Heaven and Hell"