Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sums
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Sums
Divers
Thread ID:
00761911
Message ID:
00762570
Vues:
15
As I understand it, the requirement is to sum [let's say] the values of the previous 6 records contents of field1 in the current records field2 beginning at record 7 [right?].

Record 7's field2 would contain the sum of records 1 through 6's field1. Record 8's field2 will contain the sum of record 2 through 7's field1, and so on.

The array is like a circular buffer. The ADEL(myAr,1) removes element 1. The remaining elements shift left (2 becomes 1, 3 becomes 2, and so on) and the current records field1 is added as element 6 of myAr. The sum for field2 would be the sum of the array's elements 1 through 6.

The method suggested in the post does a single top to bottom pass through the DBF without a goto.

>go 200, getting the myfield value,
yes, a record needs to be pointed to or data needs to be collected (array or memory variable) when the pointer is moved. It could be serviced geometrically with goto, but that would require 6 hits on each record. The posted method only hits the record once.

Also, if the summary used an index, the program would have to "memorize" the goto record numbers, because the natural order may not sync with the indexed order.

>and then returning to record 300?
>
>Because it would seem that doing a "go 200" would be slow compared to some kind
>of native vfp command that knew how to return the value for myField.record = 200
>Thanks very much
>Steve
Imagination is more important than knowledge
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform