Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!uunet!intercon!amanda@intercon.uu.net From: amanda@intercon.uu.net (Amanda Walker) Newsgroups: comp.sys.mac.programmer Subject: Re: Config File Resource Blues Message-ID: <1165@intercon.UUCP> Date: 10 Jul 89 17:03:09 GMT References: <2013@dogie.macc.wisc.edu> Sender: news@intercon.UUCP Reply-To: amanda@intercon.uu.net (Amanda Walker) Organization: InterCon Systems Corporation Lines: 35 In article <2013@dogie.macc.wisc.edu>, yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) writes: > This looks good. My only statement is that my DATA will more than > likely change size between reading it and writing it. In which > case I would have to do a SetHandleSize, correct? There's another approach, which I use and have never had any problems with, and goes something like this: read_settings: OpenResFile // open the settings file GetResource // get settings resource DetachResource // detach it from the resource map CloseResFile // close the settings file at this point, my settings resource is just another handle, which I can dispose of after I'm done with it. write_settings: CreateResFile (if it's not already there) OpenResFile // open the settings file if (GetResource) // if there's an old setting resource, RmveResource // remove it AddResource // add the current settings as a resource CloseResFile // close the settings file This way, I don't have to worry about the resource changing size, or whatever. As another trick, you can put a default settings resource in your application, so that you don't have to worry about the settings file not being there the first time. -- Amanda Walker InterCon Systems Corporation amanda@intercon.uu.net | ...!uunet!intercon!amanda