[Gambas-user] multidimensional array of integers

ron ronstk at ...239...
Tue Jan 15 17:01:20 CET 2008


On Tuesday 15 January 2008 12:00, gaupe wrote:
> Ron Thanks for pointing me in the right direction.
> My mistake was apperently that i did not realise that it is not possible to
> do this with a single statement.
> if have some ancient experience with clipper5 an old database like language
> and (i looked it up ;-)
> it was as .... simple.. as
> 
> 'asort( anArray,,,{|x,y| x[2] >= y[2] .AND. IIF( x[2] = y[2], x[1] <
> y[1],.T.)})

I asume this is clipper code, a friend of my did/still use it. :)

> 
> you would think that after all those years these simple things would be
> functions classes or whatever
> these are called, easy to use as these are the basics. same with dynamical
> multidimensional arrays.
> 

For most basic sort there is a command/method in many languages.
Most of them are single dimension.

For the double or more dimensions you should note that in every
dimension the type of the cell can be nummeric or string based.
This makes it more complex to write a general class for it.
Once I did write for a module in VBA to manage this in a MS Access
database where many sorts had to be done.
This module was very big because all those variable types.
Sorting numbers as value or as string need different ways.

For usage you need to give the arrays but for every cell in those 
array the method to handle the cell before the sort.

In PHP you can do such things with callbacks for the compare.
Very powerfull.

For your example code i see you did read and used the examples given.


> btw the a.max does not seem to work also not a.max[0] or a[0].max
> so i used a.bounds[0]  for that


Regarding the gambas help the UBound(arrMyArray) should be
arrMyArray.Max. If that isn't the case then maybe a bug or 
it is replaced by arrMyArray.Bounds. Not clear to me.
I expect the .Bounds is an array where .Bounds[0] is the lower 
index as LBound() and .Bounds[1] same as UBound().

Maybe Benoit can explain.

Ron






More information about the User mailing list