[Gambas-user] Which way of storing these data would you choose?

Rolf-Werner Eilert rwe-sse at osnanet.de
Fri Dec 13 15:39:44 CET 2019


Am 09.12.19 um 19:12 schrieb T Lee Davidson:
> On 12/9/19 12:19 PM, Rolf-Werner Eilert wrote:
>> The second idea was to have a number of arrays for each declaration, 
>> having a name like the value and a datatype which fits the data. The 
>> values for each declaration could be referenced via one pointer to all 
>> arrays. The drawback would be, I would have more than a dozen single 
>> arrays which I would have to maintain each time.
> 
> It sounds like perhaps you want an array of collections (Collection[]). 
> Values in a collection are variant.
> ["name": "paragraph1", "indentation": 4, "justification": "left", 
> "font": "sans-serif", "size": 12]
> 
> Dim MyCollection as New Collection[]
> 
> Paragraph one could be MyCollection[0], paragraph two, MyCollection[1], 
> etc. This assumes, though, that the paragraphs would have a related 
> context, ie. be in the same document.
> 
> 

Thank you for this idea, this is the way I choose and it proved to be 
the solution for me.

Moreover, I had never really paid attention to Collections, now I know 
they can be of great help. There are some glitches, but I could overcome 
all of them. What surprised me most was that when you do

myCollection = listOfCollections[x]

then myCollection just points to this one listOfCollections[x]. When you 
change something in myCollection, it is simultaneously changed whithin 
the array. So I used

myCollection = listOfCollections[x].Copy()

(beware, you have to use the brackets!), that will be independent.

There is one thing, the documentation for collections is not complete, 
on many pages there is only an error message.

But I got it done, so thank you all for your ideas, maybe next time I 
will try classes :)

Regards
Rolf


More information about the User mailing list