In the case of array based solution it's better to start with the item from the first row
lnMax = MyArray[1,2]
FOR lnFor = 2 TO ALEN(MyArray,1)
lnMax = MAX(lnMax, MyArray[lnFor,2])
ENDIF
>>I have an array MyArray(100,5)
>>I want to search for maximum value in column 2 in MyArray
>>What is the best way to do this?
>>Thanks for your help
>
>I don't know what is faster cicle through array or in cursor, but you could try it:
>
>lnMax = 0
>FOR lnFor = 1 TO 100
> lnMax = MAX(lnMax, array[lnFor,2]
>NEXT
>
>** or
>CREATE CURSOR crsTest (a1 C(20), a2 N(14,2), a3 .....)
>INSERT INTO crsTest FROM ARRAY MyArray
>SELECT MAX(a2) INTO CURSOR crsTest
>
>
>BYW when I need such big array I prefer to use CURSOR instead of array.
--sb--