Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find max value in array
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01109569
Message ID:
01109575
Vues:
18
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform