[Gambas-user] Array.Add question

Rolf-Werner Eilert eilert-sprachen at ...221...
Wed Jul 15 16:07:04 CEST 2015


Am 15.07.2015 15:41, schrieb Tobias Boege:
> On Wed, 15 Jul 2015, Rolf-Werner Eilert wrote:
>> Sometimes... ok: Never done this before, so I just ask:
>>
>> Dim sTest as String[0,0]
>>
>> sTest.Add("Hello", "World")
>>
>> Where is "Hello" now? At 0,0 or 1,1? Or: Which dimension is added?
>>
>> Is that possible - or are multi-dimensional arrays not dynamic?
>>
> If Benoit didn't change it (I lost track of all the changes lately due to
> exams), multidimensional arrays are static in size. One reason may be
> precisely that the choice of a particular dimension to which an Add()
> method would add elements is hard to justify.
>
> [ One additional point may be memory consumption: we imagine an n-
>    dimensional array as an n-dimensional hyperrectangle. If we increment
>    the size in one dimension, a whole (n-1)-dimensional hyperrectangle has
>    to be added. ]
>
> Anyway, if you want a refresher on your options regarding arrays in Gambas,
> I already wrote about it on this list [0] and even in German [1]. You may
> want to use what we call "derived" multidimensional arrays.
>
> Regards,
> Tobi
>
> [0] http://sourceforge.net/p/gambas/mailman/message/32228140/
> [1] http://gambas-club.de/viewtopic.php?f=3&t=4688&p=9975#p9975
>

Uuh interesting - thanks for the links!

I just wasn't sure about this, maybe mentioning it in the help chapter 
for DIM would make it clear.

What I've done so far to overcome this: When I have string arrays, I put 
in data with tabbed fields and unpack them line for line with Split. 
It's a bit roundabout, but highly flexible and rather fast.

Regards
Rolf





More information about the User mailing list