Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!ux1.cso.uiuc.edu!resnick From: resnick@cogsci.uiuc.edu (Pete Resnick) Newsgroups: comp.sys.mac.programmer Subject: Re: Why won't ResError return the right message? Message-ID: <1991May6.195837.10934@ux1.cso.uiuc.edu> Date: 6 May 91 19:58:37 GMT References: <1696@babcock.cerc.wvu.wvnet.edu> Sender: usenet@ux1.cso.uiuc.edu (News) Organization: University of Illinois at Urbana Lines: 25 vrm@blackwater.cerc.wvu.wvnet.edu (Vasile R. Montan) writes: >As you can see, the soundness of the code relies on ResError to >tell if anything has gone wrong. However, I tried testing the >code by removing the crucial resource and running this code again. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ As documented, if there is no resource of the type requested when you make a GetResource call, ResError will return noErr, but the handle you get back will be nil. On GetResource calls, always check the handle to see if it was nil. Only use the value of ResError once you have a nil value to figure out what went wrong. myHandle = GetResource(myType, myNumber); if(myHandle == 0L) return(ResError() ? ResError() : resNotFound); That's the way I usually do it. pr -- Pete Resnick (...so what is a mojo, and why would one be rising?) Graduate assistant - Philosophy Department, Gregory Hall, UIUC System manager - Cognitive Science Group, Beckman Institute, UIUC Internet/ARPAnet/EDUnet : resnick@cogsci.uiuc.edu BITNET (if no other way) : FREE0285@UIUCVMD