[comp.sys.mac.programmer] How Can I install a VBL Task from an INIT?

domenikos@emass.enet.dec.com (George Domenikos) (09/05/90)

Hi there,
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.

IS IT POSSIBLE TO INSTALL A VBL at INIT?
HOW?
EXAMPLES?


Thanks for any help.
george domenikos

jason@ux1.cso.uiuc.edu (Jason) (09/07/90)

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^ );
-- 

                       |  |    |====================|
                       |  |    | Jason Watts        |
                     \ |\ |\ \ | (jazzin@uiuc.edu)  |

stevec@Apple.COM (Steve Christensen) (09/07/90)

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."
____________________________________________________________________