Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!apple!agate!pasteur!ic.Berkeley.EDU!eta From: eta@ic.Berkeley.EDU (Eric T. Anderson) Newsgroups: comp.sys.mac.programmer Subject: Re: Why do Managers fail when called from code resources? Summary: Need to restore 'DATA' resource pointer Message-ID: <18141@pasteur.Berkeley.EDU> Date: 10 Oct 89 00:49:32 GMT References: <52218@tiger.oxy.edu> Sender: news@pasteur.Berkeley.EDU Reply-To: eta@ic.Berkeley.EDU.UUCP (Eric T. Anderson) Distribution: usa Organization: U.C. Berkeley EECS CAD Group Lines: 41 In article <52218@tiger.oxy.edu> sonenbli@oxy.edu (Andrew D. Sonenblick) writes: > > > The problem began with MenuManager calls from code resources > (which are locked, detached, unpurgable and in the system zone)... > ... > ... Now, I find that other Managers > also fail to operate properly. If my code resources put up a > window the WindowMgr seems to whimsically decide whether to put > up the window or not! Dialogs don't works properly, either. > Any time I use Pascal Str255 (I'm using LSC) such as in the call > DrawString(&myString) I get nothing (the big null, nil, void) or > garbage! > ... The reason your manager calls are failing is probably because you are not getting a hook to your 'DATA' resource in LSC. Any string that you might pass, (e.g. "This" or "\pThat") is probably not getting located properly. For example, if you compile your code to be a driver and use LSC to get your code up and running, whenever the driver gets called, LSC is nice enough to restore your global environment by pointing A4 at the 'DATA' resource (which should be 'SYS' -- assuming that you are going to be using this resource after the application heap gets purged). (This works great for installing drivers and having them stick around.) However, if you put in a mechanism so that your code gets called without the intervention of LSC, you must restore your environment yourself or just not use global variables, etc... I believe the LSC manual suggests keeping a hook to your 'DATA' resource kept in the code within a "DC.W" assembly directive, into which you store a handle to your stuff. Good luck with this. Eric Anderson eta@ic.berkeley.edu Disclaimer: All Emcompassing.