[Gambas-user] gb3: using array of structures with dimensions unknown until runtime

Benoît Minisini gambas at ...1...
Wed Jul 4 22:27:29 CEST 2012


Le 04/07/2012 06:06, Kevin Fishburne a écrit :
> I need to create a 2D array of a structure like this:
>
> Public Struct Tile_Normals
>     A[3] As Single  ' Normal for quad subsurface A.
>     B[3] As Single  ' Normal for quad subsurface B.
> End Struct
>
> Dim Normals As New Tile_Normals[TileGrid.Size, TileGrid.Size]

--> There Tile_Normals is used like a class, not a structure.

You must initialize each element of the array with a new Tile_Normals 
object (in other words, you can use a normal class instead of a structure).

Or you can use embedded array of structures:

Private Normals[10, 10] As Struct Tile_Normals

But then the size of the array must be known at compile time!

-- 
Benoît Minisini






More information about the User mailing list