Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!apple!claris!UUCP!peirce From: peirce@outpost.UUCP (Michael Peirce) Newsgroups: comp.sys.mac.programmer Subject: Re: INITs and Animation... Message-ID: <0B01FFFB.epakbg@outpost.UUCP> Date: 4 May 91 05:06:10 GMT Reply-To: peirce@outpost.UUCP (Michael Peirce) Organization: Peirce Software Lines: 38 X-Mailer: uAccess - Mac Release: 1.1.b3 In article <1991May3.155215.4115@ulrik.uio.no>, kmork@ulrik.uio.no (Knut Mork) writes: > > 2) I'm trying to patch a piece of code into the VBL manager with an INIT so > I have this piece of code running in the background (like screensavers do). > Unfortunately, the code goes away with the rest of the INIT, and I can't > get it to stay in memory. Can anyone help me? One way is to load a standalone code resource into the system heap, detach it from the resource manager and pass it's address as a completion routine to something (like the time manager for example). SetZone(SystemZone); codeH := Get1Resource('ExCo',kExampleCodeResourceID); DetachResource(codeH); HNoPurge(codeH); {is this needed?} HLock(codeH); SetZone(ApplicZone); ...later... someParameterBlock.ioCompletion := codeH^; ...and do an asynchronous operation... Other people like to keep the code in the INIT and detach the INIT itself. I prefer a seperate resource so the actual INIT code doesn't have to take up space in the heap. Oh yes, of you use the above technique make sure that the routine you want called is the first routine in the resource. -- michael -- Michael Peirce -- outpost!peirce@claris.com -- Peirce Software -- Suite 301, 719 Hibiscus Place -- Macintosh Programming -- San Jose, California 95117 -- & Consulting -- (408) 244-6554, AppleLink: PEIRCE