Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mailrus!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: How can a CDEV "talk" to its INIT? Message-ID: <9282@hoptoad.uucp> Date: 14 Dec 89 05:24:14 GMT References: <8183@cs.yale.edu> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 32 In article <8183@cs.yale.edu> kishon-amir@CS.Yale.EDU (amir kishon) writes: >I would like to write a CDEV that can change the global variables of a >patch to GetNextEvent (the patch was done by an INIT that I wrote). >How can I have both the CDEV and the patch (INIT) point to the same >global variables, so the CDEV can change those values? There are a number of ways, none of which are great. You could use a driver merely to communicate between the two, but this uses up a unit table slot. In your case, I'd recommend a sort of overloading of your trap patch. One of the simplest ways to do this would be: Stash some distinctive value in the event record. For instance, make the whole thing a Pascal string containing the name of your INIT. The patch checks this every time, and if the event record is actually a string with the correct contents, and the event mask excludes all events, then stick a pointer to the global storage into the event message of the null event you return. This way, even if by some thermodynamic miracle you wind up getting passed an event record containing this string, with an event mask of zero, you still return a valid null event. If your CDEV does one of these strange GetNextEvent calls, though, it will gain access to its globals. Messy, yes, but very low-risk and reasonably efficient. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Now hear a plain fact: Swedenborg has not written one new truth: Now hear another: he has written all the old falshoods. And now hear the reason. He conversed with Angels who are all religious, & conversed not with Devils who all hate religion..." - Blake, "The Marriage of Heaven and Hell"