Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find max value in array
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01109569
Message ID:
01109578
Views:
16
Of course, I just assumed that all values are positive and bigger than 0 :o(


>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.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform