Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!psuvax1!psuvm!cxt105 Organization: Penn State University Date: Tuesday, 26 Mar 1991 08:53:30 EST From: Christopher Tate Message-ID: <91085.085330CXT105@psuvm.psu.edu> Newsgroups: comp.sys.mac.programmer Subject: Summary - INIT/cdev communication Now that several people have pointed out to me the error of my ways in thinking that I could keep a resource from my INIT file open at all times, here's the suggested "most neato-keen way" to share information between an INIT and a cdev (or an INIT and an application, or for that matter just about anything): Gestalt. For people like me who don't understand what that implies, I'll summarize chapter 3 of Inside Mac VI by saying that basically the Gestalt Manager lets you specify a "system parameter" that other programs can query at any time. If you put the function that returns the parameter in the system heap (z.B. in your INIT's code resource) then it'll stay around until restart time. To set up INIT/cdev communication, you allocate a block of memory somewhere to act as a shared data space. Then, you set up a Gestalt selector that returns a handle to that data space. All the cdev has to do is ask Gestalt for that selector -- if it exists, the cdev knows that the INIT was installed, and goes ahead and uses whatever data it needs to. If the selector doesn't exist, the cdev knows that the INIT wasn't installed, and gives an appropriate error. If the info in the data block includes things like the dirID and name of the INIT/cdev file, the cdev can also easily write any changes in persistent parameters back to disk for the next time the machine is restarted. The only drawback is that the Gestalt calls require System 6.0.4 or later. ------- Christopher Tate | Mercy (noun): | The infrequent art of turning Bitnet: cxt105@psuvm | thumbs-up on your opponent at Uucp: ...!psuvax1!psuvm.bitnet!cxt105 | the end of your rapier.