FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBROWSE Error on :nFooterType == AGGR_MIN
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
XBROWSE Error on :nFooterType == AGGR_MIN
Posted: Thu Jun 08, 2017 06:54 AM
In method MakeTotals() is an error with AGGR_MIN or AGGR_MAX. I have marked with //WHY and //ERROR

Code (fw): Select all Collapse
   if ! Empty( aCols )

      for each oCol in aCols
         WITH OBJECT oCol
            DEFAULT :nFooterType := AGGR_SUM
            :nTotal := :nTotalSq := 0.0
            :nCount := 0
            if :nFooterType == AGGR_MIN .or. :nFooterType == AGGR_MAX     //WHY
               :nTotal := Nil                          //WHY
            endif                     //WHY
         END
      next

      nCols    := Len( aCols )
      uBm      := ::BookMark()
      Eval( ::bGoTop )
      k := 1
      ::KeyCount()
      if ::nLen > 0
         do
            for each oCol in aCols
               WITH OBJECT oCol
                  nValue   := :SumValue()
                  if nValue != nil
                     :nCount++
                     if HB_ISNUMERIC( nValue )
                        if :nMinVal == nil .or. nValue < :nMinVal
                           :nMinVal   := nValue
                        endif
                        if :nMaxVal == nil .or. nValue > :nMaxVal
                           :nMaxVal   := nValue
                        endif
                        :nTotal    += nValue                             //ERROR as :nTotal above in code set to nil
                        :nTotalSQ  += ( nValue * nValue )
                     endif
                  endif
               END
            next n
         until ( ++k > ::nLen .or. ::Skip( 1 ) < 1 )
      endif
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBROWSE Error on :nFooterType == AGGR_MIN
Posted: Thu Jun 08, 2017 09:33 AM
Mr Gunther

Thanks

We modify this code
Code (fw): Select all Collapse
            if :nFooterType == AGGR_MIN .or. :nFooterType == AGGR_MAX
               :nTotal := nil
            endif

as
Code (fw): Select all Collapse
            if :nFooterType == AGGR_MIN .or. :nFooterType == AGGR_MAX
               :nMinVal := nil // necessary
               :nMaxVal := nil // necessary
            endif


New thought to extend MAX and MIN to other types also
For the existing code:
Code (fw): Select all Collapse
                     if HB_ISNUMERIC( nValue )
                        if :nMinVal == nil .or. nValue < :nMinVal
                           :nMinVal   := nValue
                        endif
                        if :nMaxVal == nil .or. nValue > :nMaxVal
                           :nMaxVal   := nValue
                        endif
                        :nTotal    += nValue
                        :nTotalSQ  += ( nValue * nValue )
                     endif

we may substitute this new code
Code (fw): Select all Collapse
                     if :nMinVal == nil .or. nValue < :nMinVal
                        :nMinVal   := nValue
                     endif
                     if :nMaxVal == nil .or. nValue > :nMaxVal
                        :nMaxVal   := nValue
                     endif
                     if HB_ISNUMERIC( nValue )
                        :nTotal    += nValue
                        :nTotalSQ  += ( nValue * nValue )
                     endif

With this change we can have AGGR_MAX and AGGR_MIN for dates and character values also

What are your comments?

When the programmer sets AGGR_MAX or AGGR_MIN he is also responsible to ensure that all values of the column should of same datatype or nil.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: XBROWSE Error on :nFooterType == AGGR_MIN
Posted: Thu Jun 08, 2017 11:20 AM

Ok, good!

Regards,
Günther
---------------------------------
office@byte-one.com

Continue the discussion