[comp.sys.atari.st.tech] rsrc_gaddr

mts10271@uxa.cso.uiuc.edu (Michael T Stepniczka) (05/06/91)

	I have been trying to figure out how to get the address
of an object in a tree using rsrc_gaddr() without any success.
The problem is that I have 2 trees, and in each tree several objects.
I can't seem to get the address of object 1 from tree 0 and object 1
from tree 1- I get the same address (obj. 1 from tree 0) for both
of them.  Is there some way to have the rsrc_gaddr distinguish the
2 objects from one another?  The Turbo C manual warns that there can
be problems getting pointers to anything other than trees, but the
explaination that you should get a pointer to the tree and then get
pointers using this root pointer doesn't seem to work since I can't
get the pointers to the children (I can't see how, anyway).

	If anyone has had this problem and figured it out, please
let me know what the solution was.  I need to be able to get the results
from multiple editable text fields and am really stumped.

	Thanks in advance,

				Michael Stepniczka
				mts10271@uxa.cso.uiuc.edu

csbrod@immd4.informatik.uni-erlangen.de (Claus Brod) (05/06/91)

mts10271@uxa.cso.uiuc.edu (Michael T Stepniczka) writes:

>	I have been trying to figure out how to get the address
>of an object in a tree using rsrc_gaddr() without any success.
>The problem is that I have 2 trees, and in each tree several objects.
>I can't seem to get the address of object 1 from tree 0 and object 1
>from tree 1- I get the same address (obj. 1 from tree 0) for both
>of them.  Is there some way to have the rsrc_gaddr distinguish the

If you have already got the address of the object tree, the
address of any object n in the tree can be calculated as

	tree address + n*sizeof(OBJECT)

sizeof(OBJECT) equals to 24.

----------------------------------------------------------------------
Claus Brod, Am Felsenkeller 2,			Things. Take. Time.
D-8772 Marktheidenfeld, West Germany		(Piet Hein)
csbrod@medusa.informatik.uni-erlangen.de
Claus Brod@wue.maus.de
----------------------------------------------------------------------

klute@tommy.informatik.uni-dortmund.de (Rainer Klute) (05/06/91)

In article <1991May6.023631.1912@ux1.cso.uiuc.edu>,
mts10271@uxa.cso.uiuc.edu (Michael T Stepniczka) writes:
|> 	I have been trying to figure out how to get the address
|> of an object in a tree using rsrc_gaddr() without any success.
|> The problem is that I have 2 trees, and in each tree several objects.
|> I can't seem to get the address of object 1 from tree 0 and object 1
|> from tree 1- I get the same address (obj. 1 from tree 0) for both
|> of them.  Is there some way to have the rsrc_gaddr distinguish the
|> 2 objects from one another?

You should use rsrc_gaddr() only to get the address of the root object of a
tree, ie.
    rsrc_gaddr (R_TREE, TREE0, &tree0Pointer);
    rsrc_gaddr (R_TREE, TREE1, &tree1Pointer);

To get the addresses of objects inside a tree use pointer arithmetic:
    objectPointer = tree1Pointer + OBJECT1

Now objectPointer references the object with index OBJECT1 inside the
object tree with index TREE1.

-- 
  Dipl.-Inform. Rainer Klute      klute@irb.informatik.uni-dortmund.de
  Univ. Dortmund, IRB             klute@unido.uucp, klute@unido.bitnet
  Postfach 500500         |)|/    Tel.: +49 231 755-4663
D-4600 Dortmund 50        |\|\    Fax : +49 231 755-2386