Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!ucsd!hub!6600pete From: 6600pete@hub.UUCP Newsgroups: comp.sys.mac.programmer Subject: Re: Saving data from one launch to another Message-ID: <3300@hub.UUCP> Date: 13 Dec 89 00:59:38 GMT References: <975@manta.NOSC.MIL> Sender: news@hub.UUCP Lines: 40 From article <975@manta.NOSC.MIL>, by lulue@manta.NOSC.MIL (Dan Lulue ): > I need to save the location of a data file from one launch to another. > The user points out the file's location via Std File, and my program > "remembers" it for the next time. I am constrained to using UNIX sytle > string pathnames. Is it preferable to save the string in a 'STR ' resource in > application's resource fork, or in the data fork? Neither. If you ever want your application to run on a network server, you can't do this, because the resource manager doesn't know about multiple simultaneous users. The file manager (data fork strategy) knows, but you don't want to use it, because the user wouldn't be able to count on settings lasting if the app lived on a server. (Plus, you'd have to do record locking for one little config string, and it would be a pain.) A better way to do this is to save a settings file in the System Folder. You can find out where that is with SysEnvirons. > I tried the resource fork by creating a 'STR ' resource, doing a GetString > (which does a GetResource('STR ',ID), changing the string pointed to by the > handle, calling ChangedResource , then WriteResource, etc. However, > the new string never shows up in the resource fork (ResEdit view) after > execution (the dummy string I placed there originally is still there). GetResource, LoadResource (depending on various settings), HNoPurge, make your change, ChangedResource, WriteResource, HPurge. This sequence is covered in IM I under ChangedResource. > Chernicoff also suggests that the data fork is a good place to store > this sort of data. Chernicoff's getting old. Do you have the second edition? Or am I thinking of another series of books? Somebody? > how does one get the vRefNum of the directory the application resides in? Do a GetVol on startup. You'll get a working directory refNum. ------------------------------------------------------------------------------- Pete Gontier | InterNet: 6600pete@ucsbuxa.ucsb.edu, BitNet: 6600pete@ucsbuxa Editor, Macker | Online Macintosh Programming Journal; mail for subscription Hire this kid | Mac, DOS, C, Pascal, asm, excellent communication skills