[Gambas-user] Multidimensional dynamic array basics

Fabien Bodard gambas.fr at ...626...
Sat Aug 22 12:43:10 CEST 2015


Well you need to understand that you make an array of array of models

To fill it :


Public StageListWall As New ObjModel[][]

StageListWall.Resize(200)

'Instanciate each x Level

For i = 1 to StageListWall.Max

  StageListWall[i] = new objModel[]

next


'Adding a Model :

hModel = new ObjModel

StageListWall[0].Add(hModel)

'To get the Model name if you have a property name :

StageListWall[0][0].Name


To Delete a model


StageListWall[0].Delete(0)


To clear All model of x level

StageListWall[x].Clear





Well i prefer far this kind of array and use it more than the
multidimentionnal way.

At gambas begin there was only Objects and array of objects... so the Array
of array was the only way to get multidimentionnal array.

I have not found any qualities to the multidimentional way .. maybe the
speed ?





Le 21 août 2015 09:39, "Gianluigi" <bagonergi at ...626...> a écrit :

> Provided that the Sardinia sun has baked my brain (in fact, since my last
> post, it would seem) example (I think correctly) that I posted, there is
> what you need and more.
> Greetings
> Gianluigi
>
> 2015-08-21 9:19 GMT+02:00 Tobias Boege <taboege at ...626...>:
>
> > On Fri, 21 Aug 2015, Kevin Fishburne wrote:
> > > On 08/21/2015 12:00 AM, Kevin Fishburne wrote:
> > > > On Wed, Aug 19, 2015 at 9:22 AM, Kevin Fishburne <
> > > > kevinfishburne at ...1887...> wrote:
> > > >
> > > >> I need to know how to declare, initialize and add elements to a
> > > >> two-dimensional dynamic array. Using trial-and-error for every
> > possible
> > > >> syntax hasn't been too helpful so far. I'd post my code but it's
> > pretty
> > > >> useless and embarrassing and I think the basic question sums it up.
> > > > On 08/19/2015 08:17 AM, Jussi Lahtinen wrote:
> > > >> You can't do it dynamically with normal syntax:
> > > >> Dim iMyArray As Integer[x, y]
> > > >>
> > > >> Instead use declaration like this:
> > > >> Dim iMyArray As Integer[][]
> > > >>
> > > >> But then, you can't access it as the normal way (iMyArray[x, y])
> > either,
> > > >> but instead:
> > > >> iMyArray[x][y] = something
> > > >>
> > > >> iMyArray[x].Add(something)
> > > >> iMyArray[x][y].Add(something)
> > > >>
> > > >> So, it's really array of arrays.
> > > > Thanks everyone for the responses. The whole quadruple bracket thing
> > > > [][] is what was confusing me. It's all good now. :)
> > > >
> > >
> > > Okay, I was wrong. I still don't know what I'm doing.
> > >
> > > I need to dynamically add elements to SomeArray[][] and the syntax
> > > eludes me. I start with this:
> > >
> > > Public StageListWall As ObjModel[][]
> > > StageListWall = New ObjModel[][]
> > >
> > > Then madness and stupidity ensues (this is but one example of dozens of
> > > combinations I've tried):
> > >
> > > StageListWall.Add([Null])
> > > StageListWall[0].Add(Null)
> > >
> > > Obviously that doesn't work, but at this point I'm trying first to
> avoid
> > > syntax errors and second to actually get it working and understand why.
> > >
> >
> > I don't see why this wouldn't work. It does in my attached project.
> >
> > Regards,
> > Tobi
> >
> > --
> > "There's an old saying: Don't change anything... ever!" -- Mr. Monk
> >
> >
> >
> ------------------------------------------------------------------------------
> >
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> >
>
> ------------------------------------------------------------------------------
> _______________________________________________
> 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