[comp.sys.apple2] Handle Dereferencing

jpenne@ee.ualberta.ca (Jerry Penner) (12/15/90)

In article <18830@netcom.UUCP> avery@netcom.UUCP (Avery Colter) writes:
>bkahn@archive.webo.dg.com (Bruce Kahn) writes:
>
>>  Im trying to change a program I have that uses SFGetFile to use SFMultiGet2
>>and am a bit stumped on something.  The value I get back from SFMultiGet2 is
>>a structure that has 2 fields, good (boolean) and namesHandle (Handle).  The
[stuff deleted]

>Ahhhh, lesseee, here it is in vol 3 of the Toolbox Ref [anyone who wants
>to sell me volume 1 can mail me anytime!].
>
>I believe a handle is a pointer to a pointer, or more precisely, a pointer
>to an array of pointers. I believe this problem would be to do a double

Not a pointer to an array of pointers.  Just a pointer to a pointer.

>
[some examples deleted]

>Avery Ray Colter    {apple|claris}!netcom!avery  {decwrl|mips|sgi}!btr!elfcat

To dereference a handle, just do:

	**handleName

In assembler, it's a tad more complex:

dpLoc	 = some direct page location (4 bytes)

	lda [handle]
	sta dpLoc
	ldy #2
	lda [handle],y
	sta dpLoc+2

	now just get info out of dpLoc using regular indirection.

NOTE:  You should lock the handle if you intend to make any toolcalls 
	between the time you dereferenced the handle and when you access
	stuff from the dereferenced pointer 'dpLoc'.

-- 
-------------
    Jerry Penner	alberta!bode!jpenne	Edmonton, Alberta, Canada