I thought this worked, but it does not

Kenneth Brody kenbrody at bestweb.net
Mon Jun 14 10:36:59 PDT 2004


Jeff Harrison wrote:
> 
> Hmm, I just got bitten by the total function again.  I thought that you
> could use this function to total up different things based on a condition,
> but it did not work the way I expected.  Here is some sample processing and
> data that demonstrates this.
> 
> Data:
> 
> Field1(30,*)    Field6(3,.0)    Field7(3,.0)
> "T"                     "1"                     "2"
> "X"                     "1"                     "2"
> 
> Processing:
> :1 eq "T":aa=tot(6):
> :1 ne "T":aa=tot(7):
> ::end:
> @wgt:::
> ::msgbox "aa="<aa:
> ::end:
> ::aa(3,.0):
> 
> The msgbox function shows aa as "2", although I would expect it to be "3"
> 
> Is this a feature?  Aren't you supposed to be able to do this?

You asked for the total of field 7 in those records where field 1 was
not equal to "T" (since the last record was not equal to "T"), not for
record_1_field_6 plus record_2_field_7.

Either use "aa=aa+6" and "aa=aa+7", or use "aa=tot(6)" and "ab=tot(7)"
and then "aa+ab" when you want their combined sum.

-- 
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody        | www.hvcomputer.com |                             |
| kenbrody at spamcop.net | www.fptech.com     | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+



More information about the Filepro-list mailing list