[comp.sys.apple2] Q: Orca/C and SFMultiGet2

bkahn@archive.webo.dg.com (Bruce Kahn) (12/07/90)

  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
namesHandle structure is a handle to another structure; bufferLength (word)
and fileEntryArray.  Im not that comfortable w/handles yet and so would
appreciate any pointers (no pun intended?) on how I would dereference the
handle namesHandle so that I can access the file array.  Some short sample
could might also be helpful...

-- 
                                          Bruce (bkahn@archive.webo.dg.com or
                                                 kahn@adam.dg.com)
  
  Standard disclaimers apply, except where prohibited by law...

avery@netcom.UUCP (Avery Colter) (12/15/90)

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
>namesHandle structure is a handle to another structure; bufferLength (word)
>and fileEntryArray.  Im not that comfortable w/handles yet and so would
>appreciate any pointers (no pun intended?) on how I would dereference the
>handle namesHandle so that I can access the file array.  Some short sample
>could might also be helpful...

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
dereference. In other words, I'm not completely sure, but this might be
treated as an array of arrays, i.e., you would do an expression like
namesHandle[fileNumber][fileAttribute].

Or, wait. fileEntryArray is the second element of a structure. OK,
so to get a pointer to a particular file's entry structure, you would
evaluate

(namesHandle->fileEntryArray)[fileEntry]

and to see a particlar attribute, you would use...

(namesHandle->fileEntryArray)[fileEntry].fileType for instance.

Is this right? Or should namesHanlde be dereffed?

-- 
Avery Ray Colter    {apple|claris}!netcom!avery  {decwrl|mips|sgi}!btr!elfcat
(415) 839-4567   "I feel love has got to come on and I want it:
                  Something big and lovely!"         - The B-52s, "Channel Z"

JWANKERL@UTCVM.BITNET ("Josef W. Wankerl") (12/17/90)

On Sat, 15 Dec 90 05:14:39 GMT Avery Colter said:
>and to see a particlar attribute, you would use...
>
>(namesHandle->fileEntryArray)[fileEntry].fileType for instance.
>
>Is this right? Or should namesHanlde be dereffed?

Well... not exactly.  You see, the namesHandle doesn't refer to
a C array.  It's an array of sorts, but you really have to work to
pull items out of the array.  If you want to wait until the
March/April issue of GS+, I've written a nice library function that
takes the handle and the number of the entry you want and pulls it
out into a standard new-style reply record for you.  The reason you
have to wait so long to get it is because I'm writing a nice program
to go along with it and all the testing for it won't be done in time
to make the January/February issue.  So you have *plenty* of time to
either (A) figure it out on your own (feel free to mail me about
this stuff, I'll be glad to answer specific questions) or even better
(B) subscribe to GS+ Magazine with disk and wait for that issue to
come out.  You'll be able to use the library in assembly, C, or
pascal.... or any language that can link a library!

>--
>Avery Ray Colter    {apple|claris}!netcom!avery  {decwrl|mips|sgi}!btr!elfcat
>(415) 839-4567   "I feel love has got to come on and I want it:
>                  Something big and lovely!"         - The B-52s, "Channel Z"

--
===> Josef W. Wankerl, Contributing Editor/Programmer for GS+ Magazine
  BITNET:  JWANKERL@UTCVM.BITNET       | America Online:  JWankerl
 ProLine:  jwankerl@pro-gsplus         |--------------------------------
Internet:  jwankerl@pro-gsplus.cts.com | "I am a Viking"  -Y. Malmsteen