Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!pacbell!att!mtuxo!mtgzz!drutx!clive From: clive@drutx.ATT.COM (Clive Steward) Newsgroups: comp.sys.mac Subject: Re: Resource file HELP Message-ID: <8729@drutx.ATT.COM> Date: 20 Sep 88 07:12:14 GMT References: <29813@bbn.COM> Organization: resident visitor Lines: 30 From article <29813@bbn.COM>, by levin@bbn.com (Joel B Levin): > > Try . . . (ResType)'TEXT' . . . in the above line, using single > quotes. "TEXT" gives a pointer to a string; 'TEXT' gives the four > ascii characters in a long, which is what you need. > Good advice, and one more thing to do is to use the error function after the line where you try to get it: hte = GetIndResource('TEXT', 256); if ((theError = ResError ()) == noErr) { ...note what happened with an alert, and skip without trying to use the handle } This way, you won't get bombs in your program, no matter what (like trying this on a file with no 'TEXT' resource of the right number, for example. Notice above, by the way, that no cast is necessary for 'TEXT' if it's a 4-character constant as required, nor for the int. With LSC, you only have to worry where a long (4 bytes) needs to be passed, and you begin with something which looks like an int or short (2 bytes). Welcome to the wonderful world of Mac programming. Clive Steward