[Gambas-user] array of object is SO needed

nando_f at nothingsimple.com nando_f at nothingsimple.com
Tue Mar 31 23:17:18 CEST 2020


I've done an array[][] of objects for Sudoku
In fact, I have 3 kinds of arrays pointing to the same single 9x9 array

9 sets of an array of 3x3 squares which point to the same 9x9
9 sets of an array of 9 for columns pointing to the same 9x9
9 sets of an array of 9 for rows pointing to the same 9x9.

It doesn't matter which way you look at it, it all points to the same 9x9
I get to address it as a nine 3x3, or nine rows or nine columns.

Each array element was a label where I could set the x,y for each.

This structure made it easier for how I did it.

There may be better, or even more efficient, but it was cool.
Gambas is pretty cool.
-Fernando (Canada)


--
Open WebMail Project (http://openwebmail.org)


---------- Original Message -----------
From: Jussi Lahtinen <jussi.lahtinen at gmail.com>
To: Gambas Mailing List <user at lists.gambas-basic.org>
Sent: Tue, 31 Mar 2020 21:20:49 +0300
Subject: Re: [Gambas-user] array of object is SO needed

> You can even use array of labels...
> 
> Jussi
> 
> On Tue, Mar 31, 2020 at 1:22 PM roberto <roberto.premoli at tiscali.it> wrote:
> 
> > hi.
> >
> > i am doing a "sudoku" game.
> >
> > i have a matrix of 81 labels, from "label1" to "label81" as containers
> > of the numbers (to show them to user)
> >
> > i have matrix to container of number (to "elaborate" them).
> >
> > To fill the textlabels  i have to do
> >
> >
> > if matrix[1] <> 0 then label1.text=matrix[1]
> >
> > if matrix[2] <> 0 then label2.text=matrix[2]
> >
> > ...
> >
> > if matrix[81] <> 0 then label81.text=matrix[81]
> >
> >
> > also to clean or assign different background color, i have to write 81
> > times the same command on different labels.
> >
> > it will be HUGE better to have array of objects  to allow some the follow:
> >
> >
> > for n = 1 to 81
> >
> >   if matrix[n] <> 0 then label[n].text = matrix[n]
> >
> > next
> >
> > At my eyes, absence of object arrays is the worsest weakness of gambas.
> >
> >
> > PS: in past i did bigger programs with hundreds of labels and all of
> > them must be worked one by one, it was a mess (doing cut and past and
> > renumbering, it is so common to do a mistake).
> >
> > Getting older, i became less used to face this weakness.
> >
> >
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> >
------- End of Original Message -------



More information about the User mailing list