I thought this worked, but it does not

Kenneth Brody kenbrody at bestweb.net
Mon Jun 14 12:14:00 PDT 2004


Jeff Harrison wrote:
[...]
> > > 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.
> 
> Ok, so you are saying that if I use the tot function multiple times with the
> assignment going to the same field, then only the last assignment is
> effective?

What I'm saying is that you have two distinct totals being generated:

> > > :1 eq "T":aa=tot(6):
                   ------  Contains the total of field 6 from those
                           records where field 1 equals "T".

> > > :1 ne "T":aa=tot(7):
                   ------  Contains the total of field 7 from those
                           records where field 1 does not equal "T".

Remember, "aa=tot(6)" does not say "add the value of field 6 into aa",
but rather "take the current running total of field 6 and store it into
field aa".  To say "only the last assignment is effective" would be a
misstatement, just as it would to make that statement for this code:

    :1 eq "T":aa=6:
    :1 ne "T":aa=7:

Obviously "only the last assignment is effective" in the sense that each
assignment replaces the contents of field aa.

-- 
+-------------------------+--------------------+-----------------------------+
| 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