Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: XFCN/XCMD string in MPW C v3.0 Message-ID: <6939@hoptoad.uucp> Date: 9 Apr 89 06:03:01 GMT References: <12964@dartvax.Dartmouth.EDU> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 25 In article <12964@dartvax.Dartmouth.EDU> earleh@eleazar.dartmouth.edu (Earle R. Horton) writes: > There is no way to implement global variables in non-application >code resources created using MPW C. Not true. I've done it several times with various version of MPW C. I cheat and initialize the entire global space to zero instead of running the actual initialization routine, but sure you can do it. You have to maintain your own A5 and do your own allocation of global storage, but that's not especially hard. I've only done this for code that installs itself in system memory (above BufPtr or in the system heap) at INIT time, but I don't see why it couldn't work for an XCMD. > Using A4 as a base for global variables is a hack, anyway. There >are situations I know of which will invalidate A4, making your global >variables useless. (Dialog filter procs, for example.) That's why you call SetUpA4() at the start of the filter proc and call RestoreA4() at the end of it -- in Lightspeed C, that is. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "If you vote for clowns, you have no right to complain that only clowns make it to the ballot." -- Tim Maroney