Message Board


Message Board > Fenix / Bennu / Gemix / DIV > types and structs

October 9, 2006, 00:21
DTM
Earthling!
821 posts

Looking at Sandman's Network.fh I discovered "type".

How is it different from a struct? Is there anything else I should know about it?

Also are structs and other stuff like that documented anywhere?

[Edited on October 9, 2006 by DTM]
____________
:o
#
October 9, 2006, 02:21
Sandman
F3n!x0r
1194 posts

With Type you can make your own variables (which will be structs basically).

Structs:
Code:
GLOBAL
Struct my_firstcoordinate;
  int x;
  int y;
End
Struct my_secondcoordinate;
  int x;
  int y;
End
BEGIN
my_firstcoordinate.x = 3;
my_secondcoordinate.y = 5;

Those structs are the same, so you can do this:
Type:
Code:
Type _coordinate
  int x;
  int y;
End
GLOBAL
_coordinate my_firstcoordinate;
_coordinate my_secondcoordinate;
BEGIN
my_firstcoordinate.x = 3;
my_secondcoordinate.y = 5;

And of course you can make dynamic structures:
Code:
Type _coordinate
  int x;
  int y;
End
GLOBAL
_coordinate pointer coordinate;
BEGIN
coordinate = alloc(2*sizeof(_coordinate));
coordinate[0].x = 3;
coordinate[1].y = 5;

____________
BennuWiki
Yes, my avatar has grey borders in IE (so get a decent browser)
ROOFLEZ ROOFLEZ
#
October 9, 2006, 14:10
DTM
Earthling!
821 posts

Okay thanks!
____________
:o
#

Message Board > Fenix / Bennu / Gemix / DIV > types and structs

Quick reply


You must log in or register to post.
Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!