[Gambas-user] Arrays of Structs

Jussi Lahtinen jussi.lahtinen at ...626...
Tue Nov 29 05:05:12 CET 2016


Seems that the arrays remain uninitialized... I'm not sure why.
Do you really need embedded arrays and structs? They are mainly for
interacting with libraries written in C, and using Pictures inside of the
struct kind of contradicts that.

I'm mean that all works if you do it with classes and initialize the arrays
as:

   '' In MapRoom class
   Public MapObjects As New MapObject[50]


  '' And this where ever you need it
  Static Private WorldMap As New MapObject[100, 100]



Jussi


On Tue, Nov 29, 2016 at 5:40 AM, Cam Era <cybercamera at ...626...> wrote:

> I expect I'm trying to do something that's not possible with Gambas, but
> I'll ask this anyway.
>
> I'm trying to create an n x n array of a STRUCT which itself contains an
> array of type STRUCT.
>
> I have this declaration:
>
>     Public Struct MapObjec
>       xPos As Integer
>       yPos As Integer
>       ObjectType As Integer
>       isVisible As Boolean
>       ObjectPicture As Picture
>     End Struct
>
>     Public Struct MapRoom
>       MapObjects[50] As MapObject
>     End Struct
>
>     Static Private WorldMap[100, 100] As MapObject
>
>
> and this code:
>
>     WorldMap[5, 10].MapObjects.yPos = 100
>
>
> which generates a "NULL object" error.
>
> Any pointers as to whether this is possible and if so, how?
>
>
> Cheers
>
> -- Cam
> ------------------------------------------------------------
> ------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list