[Gambas-user] About Gambas arrays
Eilert
eilert-sprachen at ...221...
Wed May 4 09:38:09 CEST 2005
Hi Fernando,
nando schrieb:
> Benoit,
>
> My transition from VB to GAMBAS is progressing.
> I want to use .ADD and .CLEAR for an array
> but the syntax and usage eludes me.
From my point of view (and after having experimented with it for a
while) I found that some hints in the help seem to be misleading.
>
> If I do the following...
>
> PRIVATE my_array [4096] as SHORT
>
> I am having a difficulty using .CLEAR
>
> my_array.clear reports it is not an object
>
> I know I am missing something in my understanding here.
> Can you aid in clearing my brain fog?
:-)
Don't know if my sun shines bright enough to heat away that fog, but
what I would do is
DIM my_array as NEW SHORT[]
To add something to the array at its end, you will use
my_array.Add(xx)
and to clear the stuff completely, you may use
my_array.Clear
The drawback is that for having a 4096 cells big array you will have to
add 4096 values first. (On the other hand, when you use a fixed-size
array like you did above, you will have to write 4096 zeros to get rid
of its values...)
But be aware that poking something into a certain position of it just
will need a
my_array[x] = y
In my programs, much of the stuff in the help about STATIC, PRIVATE and
so on works different from how it's explained, but this may be due to
the fact that I use modules rather than classes (I found that they react
differently here).
Rolf
More information about the User
mailing list