Page 1 of 1

OK, call me suspicious...

Posted: Thu Oct 30, 2003 4:02 pm
by dmoc
...this works! 8O 8O

What's the point of the post? Earlier PB versions had a problem getting address of a structured variable inside a structure. Now thats ok (as the first part of the code below shows) but I've just discovered (see second part of code) that we can now use pointer vars in structures declared as pointers and useable without the "*" (contrary to many many previous postings). I'm suspicious that this is an unofficial "feature" or something. Can anyone (pref Fred) confirm that this behaviour is as designed and will remain in future PB versions?

Code: Select all

Structure strA
  r.f
  g.f
  b.f
EndStructure

Structure strB
  n.l
  c.strA
  x.l
  *p.strA
EndStructure

objA.strA
objB.strB

Debug "Sub-structure Addressing"
Debug "========================"
Debug ""
Debug "Should be same)..."
Debug ""
Debug "    @objB\c   = "+Str(@objB\c)
Debug "    @objB\c\r = "+Str(@objB\c\r)
Debug ""

Debug "Structure Pointers in Structures"
Debug "================================"
Debug ""
Debug "objA\r should be set via objB ptr..."
Debug ""
objA\r = 0
Debug "objA\r   = "+Str(objA\r)+" (before)"
objB\p = @objA
objB\p\r = 999 ; <<< Look ma, no star!
Debug "@objA    = "+Str(@objA)
Debug "objB\p   = "+Str(objB\p)
Debug "objB\p\r = "+Str(objB\p\r)
Debug "objA\r   = "+Str(objA\r)+" (after)"
Debug ""

Posted: Thu Oct 30, 2003 8:29 pm
by PolyVector
I believe this is intended... I've been using pointers-to-structures in structures that way for some time...

Posted: Thu Oct 30, 2003 10:53 pm
by dmoc
I realised after posting it's prob to do with the recent com/dx stuff. It's not clear from the help though.