Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AVERAGE doesn't work with NEXTand FOR: why ??
Message
From
19/12/2005 02:16:35
 
 
To
19/12/2005 01:42:36
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP5
Miscellaneous
Thread ID:
01079075
Message ID:
01079082
Views:
23
>>hi,
>>Whats wrong here ??
>>
>>
>>create cursor foo (f1 N(2),f2 c(2))
>>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")
>>insert into foo values(3,"BB")
>>insert into foo values(2,"AA")
>>
>>Average f1 next 2 for f2 = "BB" to m.myvar
>>
>>?m.myvar && this returns 0
>>
>>
>>any thing wrong ???
>>
>>how to put this right ??
>>
>>suhashegde
>
>
>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")
>
>Average f1 for f2 == "BB" to m.myvar
>
>?m.myvar && this returns 2
>
>Average f1 all WHILE _tally < 1 for f2 == "BB" to m.myvar
>
>?m.myvar && this returns 1
>
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform