If I have this array
aData:= { {"B", 0.2, 0.1 ,3.6 ,0.7},;
{"T", 0.2, 0.75 ,3.6 ,0.5},;
{"T", 0.2, 1.2 ,3.6 ,0.4},;
{"T", 0.2, 1.6 ,3.8 ,0.4},;
{"T", 0.2, 1.6 ,3.6 ,0.4},;
{"T", 0.2, 1.6 ,3.6 ,0.4} }
I would like to find the largest number of the 4th array column ( adata[n][4])
how I must make ?
thanks
I made
nHeightold:= adata[1][4]
For n= 1 to Len(adata)
If adata[n][4]>nHeightold
nHeightBig:= adata[n][4]
nHeightold:= adata[n][4]
Endif
next
but I believe there is a better method
search a big value on an array
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
search a big value on an array
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: search a big value on an array
Silvio,
Why don't you sort the array first
aData := ASort(aData,,,{|x,y| (x[4]>y[4]})
The largest number is in adata[1,4].
Why don't you sort the array first
aData := ASort(aData,,,{|x,y| (x[4]>y[4]})
The largest number is in adata[1,4].
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- FranciscoA
- Posts: 1964
- Joined: Fri Jul 18, 2008 1:24 am
- Location: Chinandega, Nicaragua, C.A.
Re: search a big value on an array
local nValMayor := 0, nCol := 4
AEval( aData, {|a| if( a[nCol] > nValMayor, (nValMayor := a[nCol], ) } )
AEval( aData, {|a| if( a[nCol] > nValMayor, (nValMayor := a[nCol], ) } )
Francisco J. Alegría P.
Chinandega, Nicaragua.
Fwxh1204-MySql-TMySql
Chinandega, Nicaragua.
Fwxh1204-MySql-TMySql