[Gambas-user] How to make multidimensional array?

Benoit Minisini gambas at ...2...
Sat Aug 30 12:23:51 CEST 2003


Le Samedi 30 Août 2003 11:42, Volker Schmid a écrit :
> Hello,
>
> I need an array with two dimensions to store pre-calculated koordinates. I
> try'd this way:
>
> ' Head of Class
> KoordX[] AS Integer[]
>
> ' Later in Sub:
> KoordX = NEW Integer[]
>
> This way I can create a one-dimensional array.
>
> But I need to store data like this:
>
> KoordX[3200,189]=100
> KoordX[1234,123]=60
> ...
>
> How can I do this? Gambas-Help does not help :-(
>
> Grüsse,
>
> Volker
>

There are two kinds of arrays in Gambas:

** "Java-like" arrays

They are objects of the following classes:
Integer[], String[], Object[], Date[], Variant[].

They have only one dimension.

You declare them this way: they are always void at startup.

DIM MyArray AS NEW Integer[]

They are dynamic, and have a lot of useful methods applying to them.

** "native" arrays

You declare them this way:

DIM MyArray[Dim1, Dim2, ... ] AS Integer/String/...

You can have up to eight dimensions.

They are NOT objects. They are allocated on the stack if you declare them 
local to a function, or inside the object data if you declare them global.

But they are not dynamic. They can't grow or shrink once declared. You can 
only only put an get data into them.

Hope things are clearer now !

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list