Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AVERAGE doesn't work with NEXTand FOR: why ??
Message
De
19/12/2005 02:33:39
 
 
À
19/12/2005 02:24:36
Suhas Hegde
Dental Surgeon
Sirsi, Inde
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6 SP5
Divers
Thread ID:
01079075
Message ID:
01079087
Vues:
23
>>
>>
>>create cursor foo (f1 N(2),f2 c(2))
>>insert into foo values(2,"AA")
>>insert into foo values(1,"BB")
>>insert into foo values(2,"AA")
>>insert into foo values(3,"BB")
>>insert into foo values(2,"AA")
>>insert into foo values(3,"BB")
>>insert into foo values(2,"AA")
>>
>>* a FOR have a ALL implicit scope
>>* f1 have not decimals, VFP format the myvar with f1's decimals   ( 0 )
>>Average f1 for f2 == "BB" to m.myvar
>>
>>?m.myvar && this returns 2
>>
>>?m.myvar*1.00 && this returns 2.33
>>
>>* a WHILE have a REST implicit scope, then you have to declare ALL
>>* a WHILE _tally < N stop the computation after N match records
>>Average f1 all WHILE _tally < 1 for f2 == "BB" to m.myvar
>>?m.myvar*1.00 && this returns 1
>>Average f1 all WHILE _tally < 2 for f2 == "BB" to m.myvar
>>?m.myvar*1.00 && this returns 1
>>
>
>
>thanx for ur reply
>
>It doent do the next 2 scope ??
>

next 2 scope is:
run within current record and next skip record
* example
* you are on record 10 with order 0 ( native table order )
* record 11 is filtered
* record 12 is not filtered
* record 13 is not filtered

NEXT 1 : compute on record 10
NEXT 2 : compute on record 10,12
NEXT 3 : compute on record 10,12,13
>How do i get the scope to work ?
>
go to the start record

>Average f1 all WHILE _tally < 2 for f2 == "BB" to m.myvar
>Average f1 all WHILE _tally < 1 for f2 == "BB" to m.myvar
>
>return m.myvar*1.00 = 2.33 om my machine

sure ?

>Average f1 all WHILE _tally < 0 for f2 == "BB" to m.myvar
>return 0 on my machine

This is ok because the first _TALLY is 0 and WHILE 0<0 stop the operation immediatelly.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform