[Gambas-user] Dynamic multi-dimensional array?

Benoît Minisini gambas at ...1...
Mon Jun 23 19:06:52 CEST 2014


Le 23/06/2014 18:12, Rezedent12 . a écrit :
> Is it possible to dynamic multi-dimensional arrays?
>
> Static multi-dimensional array may declare Ps As New Integer [10,100]
>
> Dynamic dimensional possibly Ps As New Integer []
>
> How to declare a dynamic multidimensional array? I tried Ps As New Integer
> [,] but it is not syntactically correct. I decided to temporarily apply Ps
> As New Integer [] []. Create a dynamic array of dynamic arrays. But this is
> not what I need [x] [y], I need to [x, y]. Is it possible?
>

You can create dynamically an array with any number of dimensions and 
any size in each dimension, but once instanciated, you cannot modify the 
size and the number of dimensions.

The only exception is arrays with one dimension, where the size can be 
increased or decreased.

So:

Dim myArray As Integer[]

myArray = New Integer[Expr1, Expr2, Expr3]

If you don't know the number of dimensions at design time, you have to 
do that:

Dim myDimensions As Integer[]

myArray = Object.New("Integer[]", myDimensions)

Regards,

-- 
Benoît Minisini




More information about the User mailing list