Path: utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!decwrl!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: How Can I install a VBL Task from an INIT? Message-ID: <10086@goofy.Apple.COM> Date: 7 Sep 90 02:41:27 GMT References: <1900@mountn.dec.com> <1990Sep6.182348.567@ux1.cso.uiuc.edu> Organization: Apple Computer Inc., Cupertino, CA Lines: 39 In article <1990Sep6.182348.567@ux1.cso.uiuc.edu> jason@ux1.cso.uiuc.edu writes: >domenikos@emass.enet.dec.com (George Domenikos) writes: >>I am having problems with installing successfully a VBL Task at INIT time. >>It seems that I crash when I do > >>myVBL.vblAddr := @DoMyVBLStuff; > >>where myVBL is of type VBLTask >>and DoMyVBLStuff is my procedure name containing the code I want to execute >>as VBL. > > Did you lock down the VBL code so that it wouldn't be moved or purged? >A good way to accomplish this is to compile the code for DoMyVBLStuff into a >resource, say of type 'task'. Your init should: > > 1) Load the 'task' code using GetResource() > 2) move the code to the top of the heap ( MoveHHi() ) > 3) HLock the code. > 4) Get a pointer to the code using: > myVBL.vblAddr = StripAddress( codeHandle^ ); Assuming the INIT is locked down, was it detached? If not, as soon as the INIT file is closed, the code goes away, and so there will be a loud crash 1/60th of a second later. If your INIT has some code that needs to hang around, do a DetachResource() on the handle to the INIT resource, which will make the Resource Manager forget about it and leave it alone... steve -- ____________________________________________________________________ Steve Christensen Internet: stevec@goofy.apple.com Apple Computer, Inc. AppleLink: STEVEC 20525 Mariani Ave, MS 81-CS CompuServe: 76174,1712 Cupertino, CA 95014 "You just contradicted me." "No I didn't." ____________________________________________________________________