Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: ResError Bug? Message-ID: <32879@apple.Apple.COM> Date: 5 Jul 89 21:49:19 GMT References: <5914@hubcap.clemson.edu> <14217@dartvax.Dartmouth.EDU> <32877@apple.Apple.COM> Organization: Apple Computer Inc, Cupertino, CA Lines: 45 In article <32877@apple.Apple.COM> cjp@Apple.COM (Chris Plummer) writes: >In article <14217@dartvax.Dartmouth.EDU> isle@eleazar.dartmouth.edu (Ken Hancock) writes: >>In article <5914@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael K O'Rourke) writes: >>>I am trying to read a PICT resource into my application. I have a if-then >>>statment which checks to see if the resource really existed, but it never >>>gets called in the error case. >>> >>>pict := PicHandle(Get1Resource('PICT',pictNumber)); >>>if ResError = noErr then >>> { do something} >>> >>>Well, i went in and found out that ResError ALWAYS returns noErr. What's up? >> >>The correct check is: >> >>if (pict <> NIL) or for C tyes if (pict != NIL ) >> >>This, by the way, is in fact documented in inside mac in the >>Resource Manager chapter. If a GetResource call cannot find >>the resource, it returns a NIL handle but does not generate >>a resource mamager error. > >Not quite. ResError will return noErr if the resource **type** is not >found. If the resource type is found but the resource is not then >ResError should return resNotFound. The is all documented in IM I-119. >By the way, if you use the Inside Mac DA, the writeup for GetResource >does not include the note from IM I that talks about ResError returning >noErr if the resource type isn't found. We just hashed this out, and I think that we determined that Get(1)Resource will never return an error if it can't find the resource it is looking for, the existance of other resources of the same type notwithstanding. This is in contrast to Get(1)Named Resource, which WILL return resNotFound under the circumstances that you would expect it to. Please note that Get(1)Resource will return other error codes when appropriate. Steve Brecher, Greg Marriott (just some guy), and myself are all in agreement on this. If you have experience otherwise, please let me know. ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. --- Developer Technical Support INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions