Structures and such

Just starting out? Need help? Post your questions and find answers here.
TimmyTom
User
User
Posts: 36
Joined: Mon Aug 18, 2003 8:32 am

Structures and such

Post 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
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

:?:

Code: Select all

Structure TGridPoint 
  p.TGLCoord 
  value.f 
EndStructure 

Structure TGridCube 
  *GridPoint.TGridPoint[8] 
EndStructure
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Structures and such

Post 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. (?)
Good programmers don't comment their code. It was hard to write, should be hard to read.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Structures and such

Post by traumatic »

...and too late again :(
Good programmers don't comment their code. It was hard to write, should be hard to read.
TimmyTom
User
User
Posts: 36
Joined: Mon Aug 18, 2003 8:32 am

Post 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
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post 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()
Post Reply