Path: utzoo!attcan!uunet!samsung!usc!apple!bionet!agate!shelby!neon!Minnie.Stanford.EDU!philip From: philip@Minnie.Stanford.EDU (Philip Machanick) Newsgroups: comp.sys.mac.programmer Subject: Re: Resource Fork data storage--related question Message-ID: <1990Jul22.230744.14761@Neon.Stanford.EDU> Date: 22 Jul 90 23:07:44 GMT References: <2172@uc.msc.umn.edu> <1990Jul17.172044.20361@Neon.Stanford.EDU> <1715MAYER-A@RICEVM1> Sender: news@Neon.Stanford.EDU (USENET News System) Reply-To: philip@pescadero.stanford.edu Distribution: na Organization: Computer Science Department, Stanford University Lines: 39 In article <2172@uc.msc.umn.edu>, souka@uh.msc.umn.edu (Omar Souka) writes: > > I have a related question. It may be more of a Pascal question than a > > Macintosh question, though. I would like to retrieve the contents > > of a (rather long) array. A resource of my own type seems > > like a logical structure for this. > > > > I know how to load a resource into memory, but I don't see how then to > > store the contents into an array I've declared... > > > > I would appreciate any suggestions or better ideas. Thanks! [...] > Reading from the resource > > 1. Call GetResource > > 2. If you need to know how big the handle is call HandleSize > > 3. BlockMove from the resource into your array > > BlockMove(*ResourceHandle,array,number_of_bytes); > > In Pascal it would look something like this (just a guess, I don't do Pascal) > > BlockMove(ResourceHandle^,@array,number_of_bytes) > Why not store the result of GetResource directly into the array? You would have to use the array through a handle, e.g., in Pascal: type arrayPtr = ^arrayType; arrayHdl = ^arrayPtr; var data : arrayHdl; begin data := arrayHdl(GetResource(...)); Saves you a blockmove (why copy data unnecessarily?). Philip Machanick philip@pescadero.stanford.edu