XBROWSE Error on :nFooterType == AGGR_MIN

XBROWSE Error on :nFooterType == AGGR_MIN

Postby byte-one » Thu Jun 08, 2017 6:54 am

In method MakeTotals() is an error with AGGR_MIN or AGGR_MAX. I have marked with //WHY and //ERROR

Code: Select all  Expand view
  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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: XBROWSE Error on :nFooterType == AGGR_MIN

Postby nageswaragunupudi » Thu Jun 08, 2017 9:33 am

Mr Gunther

Thanks

We modify this code
Code: Select all  Expand view

            if :nFooterType == AGGR_MIN .or. :nFooterType == AGGR_MAX
               :nTotal := nil
            endif
 

as
Code: Select all  Expand view

            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: Select all  Expand view

                     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: Select all  Expand view

                     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
User avatar
nageswaragunupudi
 
Posts: 10207
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBROWSE Error on :nFooterType == AGGR_MIN

Postby byte-one » Thu Jun 08, 2017 11:20 am

Ok, good!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 13 guests