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

Rolf-Werner Eilert rwe-sse at osnanet.de
Mon Dec 9 18:19:00 CET 2019


Hi folks,

Just cannot decide what would be easier for me. Maybe you have an advice 
or two :)

There is a number of definitions for things (in my case, it's text 
paragraphs). There is name, indentation, left/rightbound/centered, font, 
size and so on for each. And there may be a dozen of declarations.

First I thought I could simply set all values for one declaration into a 
TAB separated string (them come from a file anyway), and the strings 
into an array. The drawback would be, I would have to keep a list of 
positions for the values, i. e. name is 0, indentation is 1, leftbound 
is 2 etc., and in each an every function poking and peeking values I 
would have to reference the values via these position numbers.

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.

I have used both methods in projects, each proved to be ok for this or 
that, but this time it's the sheer number of values to be stored for 
each declaration which makes both seem somewhat... roundabout.

Is there a better, a more compact way I have missed? Actually, it's like 
a table of values. Maybe something like structs? (In the help text for 
structs, I am warned to use structs...) Isn't there a more Gambas way to 
achieve this, something that ends up with some myArray.thisValue[] 
pointing to each value?

Thank you for your insight!

Regards
Rolf


More information about the User mailing list