Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sdd.hp.com!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!uw-beaver!cornell!vax5.cit.cornell.edu!u2zj From: u2zj@vax5.cit.cornell.edu (Stanton Loh) Newsgroups: comp.sys.mac.programmer Subject: creating resources Message-ID: <1991Mar22.163118.3560@vax5.cit.cornell.edu> Date: 22 Mar 91 20:31:18 GMT Distribution: comp Organization: CIT, Cornell University Lines: 44 In article <1991Mar21.234809.26603@ux1.cso.uiuc.edu>, resnick@cogsci.uiuc.edu (Pete Resnick) writes: [...] > Three things: > 1. You *really* don't want to create a resource with thousands > of integers anyway. There is a Tech Note on why not to abuse > the Resource Manager in just this way. I would be much better > to use the data fork of the file to store your integers. If > you need them in memory, just read them into a handle from there. > I believe you misunderstand tech note 74. What is not allowed is to treat the resource fork in the same way as the data fork, ie you cannot use PBOpenRFto open the resource fork and just start blasting in your own data. A valid resource fork begins with a resource header - not your data. What is fine (and what I think the original question asked) is how to create your own resource, fill it with whatever you want, so you can use GetResource() to get a Handle to it during run time. For example (error checking deleted for brevity sake) to create a resource file with your own resource N integer long of type 'MINE', number 200 named "MyResource" (in ThinkC): Handle resHandle; int *resPtr, refNum; resHandle = NewHandle(N*sizeof(int)); /* create Handle to res */ HLock(resHandle); /* lock and dereference */ resPtr = (int *) *resHandle; for (i=0; i