Page 1 of 1

Structures and such

Posted: Mon Jan 03, 2005 7:01 am
by TimmyTom
I've been fighting with this all day now.. please assist if possible.

In delphi i'd do this:

Code: Select all

  TGridPoint = record
    P : TGLCoord;
    Value : FLoat;
  end;
  PGridPoint = ^TGridPoint;
  TGridCube = record
    GridPoint : Array [0..7] of PGridPoint;
  end;
(^ in the Delphi code is a pointer)

Now, i have tried just about everything to get this to translate to PureBasic.

Code: Select all

Structure TGridPoint
  p.TGLCoord
  value.f
EndStructure

*PGridPoint = TGridPoint

Structure TGridCube
  *GridPoint.PGridPoint[8]
EndStructure
This gives an error deep in the code about an undefined structure (PGridPoint).

I need the structure TGridCube to point to whatever is inside the structure TGridPoint (hard to explain how i use it in code, but it's used for a load of math)

Is there any way to do what Delphi does without even breaking a sweat?

Tim

Posted: Mon Jan 03, 2005 7:17 am
by FloHimself
:?:

Code: Select all

Structure TGridPoint 
  p.TGLCoord 
  value.f 
EndStructure 

Structure TGridCube 
  *GridPoint.TGridPoint[8] 
EndStructure

Re: Structures and such

Posted: Mon Jan 03, 2005 7:18 am
by traumatic
I could be wrong but isn't it just like this?

Code: Select all

Structure PGridPoint
  p.GLCoord ; to be defined further... (x.f, y.f, z.f ?)
  value.f
EndStructure

Structure TGridCube
  GridPoint.PGridPoint[7]
EndStructure
I could imagine you don't need all that pointer stuff. (?)

Re: Structures and such

Posted: Mon Jan 03, 2005 7:18 am
by traumatic
...and too late again :(

Posted: Mon Jan 03, 2005 7:29 am
by TimmyTom
I actually do need it as a pointer inside the structure, otherwise i have to write EIGHT times as much code for what i am doing!

Tim

Posted: Mon Jan 03, 2005 7:42 am
by FloHimself
this is a pointer to the structure:

Code: Select all

*GridPoint.TGridPoint[8] 
this is not:

Code: Select all

GridPoint.TGridPoint[8] 
check the struct sizes with SizeOf()