Hi Med + Sieghard.

I would propose this:

procedure tmsebufdataset.sumfield(const afield: tfield; out asum: currency);
var
 int1,int2: integer;
 index1: integer;
 po1: precheaderty;
 po2: pprecheaderty;
 bo1,bo2: boolean;
 state1: tdatasetstate;
begin
 checksumfield(afield,[ftinteger,ftbcd,ftfloat]); // this changed
 index1:= afield.fieldno - 1;
 asum:= 0;
 bo1:= filtered and assigned(onfilterrecord);
 state1:= settempstate(tdatasetstate(dscheckfilter));
 try
  int2:= ffieldinfos[index1].base.offset;
  po2:= pointer(findexes[0]);
  case ffieldinfos[afield.fieldno-1].base.fieldtype of
   ftinteger: begin                              // this added
    if bo1 then begin
     for int1:= 0 to fbrecordcount - 1 do begin
      fcheckfilterbuffer:= pdsrecordty(pchar(ppointeraty(po2)[int1])-
                                                         
sizeof(dsheaderty));
      bo2:= true;
      onfilterrecord(self,bo2);
      if bo2 and getfieldflag(
              @fcheckfilterbuffer^.header.fielddata.nullmask,index1) then
begin
       asum:= asum + pinteger(pchar(@fcheckfilterbuffer^.header)+int2)^;
      end;
     end;
    end
    else begin
     for int1:= 0 to fbrecordcount - 1 do begin
      po1:= ppointeraty(po2)^[int1];
      if getfieldflag(@po1^.fielddata.nullmask,index1) then begin
       asum:= asum + pinteger(pchar(po1)+int2)^;
      end;
     end;
    end;
   end;
   ftbcd: begin
    if bo1 then begin
     for int1:= 0 to fbrecordcount - 1 do begin
      fcheckfilterbuffer:= pdsrecordty(pchar(ppointeraty(po2)[int1])-
                                                         
sizeof(dsheaderty));
      bo2:= true;
      onfilterrecord(self,bo2);
      if bo2 and getfieldflag(
              @fcheckfilterbuffer^.header.fielddata.nullmask,index1) then
begin
       asum:= asum + pcurrency(pchar(@fcheckfilterbuffer^.header)+int2)^;
      end;
     end;
    end
    else begin
     for int1:= 0 to fbrecordcount - 1 do begin
      po1:= ppointeraty(po2)^[int1];
      if getfieldflag(@po1^.fielddata.nullmask,index1) then begin
       asum:= asum + pcurrency(pchar(po1)+int2)^;
      end;
     end;
    end;
   end;
   ftfloat: begin
    if bo1 then begin
     for int1:= 0 to fbrecordcount - 1 do begin
      fcheckfilterbuffer:= pdsrecordty(
                          
pchar(ppointeraty(po2)^[int1])-sizeof(dsheaderty));
      bo2:= true;
      onfilterrecord(self,bo2);
      if bo2 and getfieldflag(
            @fcheckfilterbuffer^.header.fielddata.nullmask,index1) then
begin
       asum:= asum + pdouble(pchar(@fcheckfilterbuffer^.header)+int2)^;
      end;
     end;
    end
    else begin
     for int1:= 0 to fbrecordcount - 1 do begin
      po1:= ppointeraty(po2)^[int1];
      if getfieldflag(@po1^.fielddata.nullmask,index1) then begin
       asum:= asum + pdouble(pchar(po1)+int2)^;
      end;
     end;
    end;
   end;
  end;
 finally
  restorestate(state1);
 end; 
end;
____________________________________________________

But if you allow to sum integers into currency variable, there is no reason
why not to do it too to sum integer into double variable.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to