I prefer the Jussi aproach, because a lot of code is already wrtitten with [r,c] format and is easier to read.
I hope that works for Public arrays! Thanks Martin > Subject: Re: [Gambas-user] Matrix resize > To: mailing list for gambas users <gambas-user@lists.sourceforge.net> > Message-ID: > <CAFkCsL6RRAU9d2B7fMzsfjZyuji0HBa7Uk=E3wmOH=vvmxm...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > You can use arrays of array > > > private MyArray as new Object[] > > Public sub _New() > ResizeMyArray(MyArray,15,12) > end > > > > Public sub ResizeMyArray(hMyArray as Object[], X as integer, y as integer) > > hMyArray.Resize(X) > > For i = 0 to hMyArray.max > if hMyArray [i] then > hMyArray[i].Resize(y) > else > hMyArray[i] = new Integer[Y] > endif > next > > > > For the call : > > value = MyArray[1][2] > > > 2013/12/5 Jussi Lahtinen <jussi.lahti...@gmail.com>: > > Unfortunately this is missing feature from Gambas. Maybe Benoit has reason > > for it, I don't know. > > > > However here is code for resizing 2D arrays: > > > > Private Function Resize2DArray(hArray As Object, SizeX As Integer, SizeY As > > Integer) As Object > > > > Dim hNewArray As Object = Object.New(Object.Type(hArray), [SizeX, SizeY]) > > Dim ii As Integer, jj As Integer > > > > For ii = 0 To Min(hNewArray.Bounds[0], hArray.Bounds[0]) - 1 > > For jj = 0 To Min(hNewArray.Bounds[1], hArray.Bounds[1]) - 1 > > hNewArray[ii, jj] = hArray[ii, jj] > > Next > > Next > > > > Return hNewArray > > > > End > > > > > > And here is how to use it: > > > > Dim iMyArray As New Integer[5, 5] > > > > iMyArray = Resize2DArray(iMyArray, 10, 10) > > > > > > As it's not native method, it's not that fast, but fortunately Gambas is > > *very* often fast enough! > > > > > > Jussi > > > > > > > > On Thu, Dec 5, 2013 at 2:20 PM, terco IDE <terco...@hotmail.com> wrote: > > > >> First of everything: BIG thanks to Benoit for creating Gambas! > >> > >> Is there any workaround for resizing matrices? > >> > >> rigth now, I'm using this code > >> > >> notMatrix.Resize(100*200) ' 100 rows, 200 cols > >> > >> ' get element [row,col] > >> > >> x = notMatrix[col + row*200] > >> > >> , and on a big program, code get's really dirty > >> > >> > >> Thanks! > >> > >> > >> Saludos > >> Martin > >> > >> ------------------------------------------------------------------------------ Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps with a single code base. Download it for free now! http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user