nCounter Report not run ok RESOLVED

User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

nCounter Report not run ok RESOLVED

Post by Silvio.Falconi »

Dear Antonio,

if I made

GROUP ON CU->STATE ;
FOOTER " » Total FOR STATE » "+::oReport:aGroups[1]:cValue +"("+ltrim(str(::oReport:aGroups[1]:nCounter))+")" ;
FONT 1

oReport:nCounter is right for each group and the total counter is right


If I not use Groups but only easy bfor sample :

ACTIVATE REPORT oReport FOR dInicio <= CU->HIREDATE .AND. CU->HIREDATE <= dFinal ;
ON END ( oReport:StartLine(), oReport:EndLine(), oReport:StartLine(), ;
oReport:Say(1, 'Total customers: '+Tran(oReport:nCounter, '@E 999,999'), 1),;
oReport:EndLine() )

give me bad nCounter

SO IFI wish print only the hiredate from 01/01/1990 to 01/011991

execute the codeblock bfor ( FOR dInicio <= CU->HIREDATE .AND. CU->HIREDATE <= dFinal ) because it print only 57 records
then print on say "total customers " 500

Image

why ?



here the test (rep21.prg)

Code: Select all


#include "FiveWin.ch"
#include "report.ch"

request DBFCDX

STATIC oReport

Function Rep21()

     LOCAL oFont1, oFont2, oFont3, oPen1, oPen2

     local dInicio :=ctod("01/01/1990")
     local dFinal  :=ctod("01/01/1991")


     DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-10
     DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-10 BOLD
     DEFINE FONT oFont3 NAME "ARIAL" SIZE 0,-10 BOLD ITALIC

     DEFINE PEN oPen1 WIDTH 3
     DEFINE PEN oPen2 WIDTH 1

     USE CUSTOMER NEW VIA "DBFCDX" ALIAS CU
  //  index on cu->state tag 1 temporary
      CU->(DbGoTop())

     REPORT oReport ;
          TITLE  "*** FiveWin Report DEMO ***",;
                 "",;
                 OemtoAnsi("by FiveTech"),;
                 "" ;
          FONT   oFont1,;
                 oFont2,;
                 oFont3 ;
          PEN    oPen1,;
                 oPen2 ;
          HEADER "Date: "+dtoc(date()),;
                 "Time:  "+time() ;
                 RIGHT ;
          FOOTER OemtoAnsi("Page: ")+str(oReport:nPage,3) ;
                 CENTERED ;
          PREVIEW

    /*  
                 //FOR TEST a GROUP
 GROUP ON CU->State ;
           FOOTER "Total State "+oReport:aGroups[1]:cValue+ ;
                  " ("+ltrim(str(oReport:aGroups[1]:nCounter))+")" ;
           FONT 2
      */
     COLUMN TITLE "ST" ;
          DATA CU->State ;
          FONT 2  ;
          GRID 2

     COLUMN TITLE "City" ;
          DATA CU->City ;
          GRID 2

     COLUMN TITLE "First Name","Last Name" ;
          DATA CU->First , CU->Last ;
          GRID 2

     COLUMN TITLE "   Salary" ;
          DATA CU->Salary ;
          PICTURE "9,999,999" ;
          SIZE 9 ;
          TOTAL ;
          SHADOW ;
          GRID

     END REPORT

     IF oReport:lCreated

          /*
          First line of title bold
          */

          oReport:oTitle:aFont[1] := {|| 2 }

          /*
          Total descriptors
          */

          oReport:cGrandTotal := "Grand Total..."
          oReport:cPageTotal := "Page Total..."

          /*
          Italic when salary greater than 100,000
          */

          oReport:aColumns[4]:bDataFont := {|| iif(CU->Salary>100000,3 ,1 ) }


     ENDIF

     ACTIVATE REPORT oReport FOR dInicio <= CU->HIREDATE .AND. CU->HIREDATE <= dFinal  ;
       ON STARTGROUP oReport:NewLine() ;
             ON END ( oReport:StartLine(), oReport:EndLine(), oReport:StartLine(), ;
                     oReport:Say(1, 'Total customers: '+Tran(oReport:nCounter, '@E 999,999'), 1),;
                     oReport:EndLine() )


     /*
     Close and release
     */

     oFont1:End()
     oFont2:End()
     oFont3:End()
     oPen1:End()
     oPen2:End()

     CLOSE CU

RETURN NIL



 





IF I made ( I saw a Nages topic)

Code: Select all

 local nCounter := 1
and then

Code: Select all

oReport:bFor := { || If((dInicio <= CU->HIREDATE .AND. CU->HIREDATE <= dFinal), (nCounter++, .t. ), .f. ) }


        ACTIVATE REPORT oReport   ;
       ON STARTGROUP oReport:NewLine() ;
             ON END ( oReport:StartLine(), oReport:EndLine(), oReport:StartLine(), ;
                     oReport:Say(1, 'Total customers: '+Tran(nCounter, '@E 999,999'), 1),;
                     oReport:EndLine() )
we have 58 records but I have only 57 records , How it was possible ?

Image


TEST WITH GROUP
But when I use GRoup command with the suggestion of NAges then the total id not right

because the records ( with bfor) are allways 57 but the ncounter is 115

Image
Last edited by Silvio.Falconi on Sat Oct 10, 2020 5:03 pm, edited 1 time in total.
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: nCounter Report not run ok

Post by nageswaragunupudi »

We will look into this
Regards

G. N. Rao.
Hyderabad, India
User avatar
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: nCounter Report not run ok

Post by FranciscoA »

It seems to be an old bug.

I have tested it with version 1204, and the results are the same
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh1204-MySql-TMySql
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: nCounter Report not run ok

Post by James Bott »

This is just a guess, but it looks like it is counting report lines instead of records.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
artu01
Posts: 306
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: nCounter Report not run ok

Post by artu01 »

Silvio.Falconi wrote:Dear Antonio,

IF I made ( I saw a Nages topic)

Code: Select all

 local nCounter := 1
and then

Code: Select all

oReport:bFor := { || If((dInicio <= CU->HIREDATE .AND. CU->HIREDATE <= dFinal), (nCounter++, .t. ), .f. ) }


        ACTIVATE REPORT oReport   ;
       ON STARTGROUP oReport:NewLine() ;
             ON END ( oReport:StartLine(), oReport:EndLine(), oReport:StartLine(), ;
                     oReport:Say(1, 'Total customers: '+Tran(nCounter, '@E 999,999'), 1),;
                     oReport:EndLine() )
we have 58 records but I have only 57 records , How it was possible ?
Silvio:
at the beginning, ncounter should be 0
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Post by Silvio.Falconi »

I have old exe app ( 16 bit) where the oReport:ncounter run ok also on groups, and I remember I used Ozlib where Report class was a class included
I made a research, this problem was from before perhaps 2009

For the test, If you think to found a good solution, You must try with alone , with bfor condition, and group condition
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Post by Silvio.Falconi »

artu01 wrote: Silvio:
at the beginning, ncounter should be 0
Dear artu01,
I have been looking for solutions for a week, turning the forum many times and all my saves from 1992 to today, from fw14.4 to the penultimate 32-bit version of 2020,
unfortunately I can't try the 16-bit exes because I have to find old 16-bit PCs and they are easy to find, but believe me I don't remember having problems with this bug

on this topic http://forums.fivetechsupport.com/viewt ... er#p110839 Mr NagesWarao explain how we must make

there is also a sample , it run for bfor condition but when you try to insert a group not run

I used his test sample and I insert group command

Code: Select all

    #include 'fivewin.ch'
    #include 'report.ch'

    REQUEST DBFCDX

    function Main()

       local cAlias, oWnd

       if ( cAlias := OpenData() ) != nil
          DEFINE WINDOW oWnd
          ACTIVATE WINDOW oWnd HIDDEN ;
             ON INIT ( ( cAlias )->( Report() ), oWnd:End() )
       endif

       ( cAlias )->( DbCloseArea() )

    return nil

    function Report()

       local oRep, oFont,oFont2
       local cAlias   := Alias(), nCounter := 0

       DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-9
       DEFINE FONT oFont2 NAME 'TAHOMA' SIZE 0,-10 bold

       DEFINE PEN oPen1 WIDTH 1
       DEFINE PEN oPen2 WIDTH 1


       REPORT oRep FONT oFont,oFont2;
                 PEN    oPen1,;
                 oPen2 ;
                 PREVIEW



          COLUMN DATA nCounter TITLE "Number" PICTURE '9999'  TOTAL
          COLUMN TITLE "UNIT" DATA 1 PICTURE "999" TOTAL
          COLUMN TITLE "First" DATA ( cAlias )->FIRST SIZE 20
          COLUMN TITLE "State" DATA ( cAlias )->STATE SIZE 5
          COLUMN TITLE "Age" DATA ( cAlias )->AGE PICTURE "9999" RIGHT
          COLUMN TITLE "Salary" DATA ( cAlias )->SALARY  PICTURE "99,999,999.99" RIGHT  TOTAL


             GROUP ON ( cAlias )->STATE ;
           FOOTER space(40)+"Total State "+oRep:aGroups[1]:cValue+ ;
                  " ("+ltrim(str(oRep:aGroups[1]:nCounter))+")" ;
           FONT 2



       ENDREPORT

        oRep:bFor := { || If(( cAlias )->SALARY > 25000 , (nCounter++, .t. ), .f. ) }

        ACTIVATE REPORT oRep ;
          ON ENDPAGE ( oRep:aColumns[ 1 ]:nTotal := nCounter ) ;
           ON END ( oRep:StartLine(), oRep:EndLine(), oRep:StartLine(), ;
                     oRep:Say(1, 'Total customers: '+Tran(oRep:nCounter, '@E 999,999'), 1),;
                     oRep:EndLine() )

    RELEASE FONT oFont

    return nil

    static function OpenData()

       local cAlias, lOpen := .f.

       cAlias := cGetNewAlias( "CUST" )
       USE c:\work\FWH\samples\customer.dbf ;
          NEW ALIAS (cAlias) SHARED VIA 'DBFCDX'
         index on (cAlias)->state tag 1 temporary
       lOpen := Select( cAlias ) > 0

    return If( lOpen, cAlias, '' )
 
the condition

oRep:bFor := { || If(( cAlias )->SALARY > 25000 , (nCounter++, .t. ), .f. ) } is not execute
each total group is ok and also oRep:nCounter for each group
at the end the oRep:nCounter is 500
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Post by Silvio.Falconi »

James Bott wrote:This is just a guess, but it looks like it is counting report lines instead of records.
right and I think the bug is on Skip method


but now with this

Code: Select all

 
ACTIVATE REPORT oRep ;
          ON ENDPAGE ( oRep:aColumns[ 1 ]:nTotal := nCounter ) ;
           ON END ( oRep:StartLine(), oRep:EndLine(), oRep:StartLine(), ;
                     oRep:Say(1, 'Total customers: '+Tran(nCounter, '@E 999,999'), 1),;
                     oRep:EndLine() )
 
could run ok
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Post by Silvio.Falconi »

OK PERHAPS WE CAN RESOLVED IT

for the Group command we can use the nCounter of Report class

Code: Select all

GROUP ON ( cAlias )->STATE ;
           FOOTER space(40)+"Total State "+oRep:aGroups[1]:cValue+ ;
                  " ("+ltrim(str(oRep:aGroups[1]:nCounter))+")" ;
           FONT 2
for the other we can add on our source nCounter local variable

sample

Code: Select all

oRep:bFor := { || If((dInicio <= ( cAlias )->HIREDATE .AND. ( cAlias )->HIREDATE <= dFinal), (nCounter++, .t. ), .f. ) }

        ACTIVATE REPORT oRep ;  //  ON ENDPAGE ( oRep:aColumns[ 1 ]:nTotal := nCounter ) ;
           ON END ( oRep:StartLine(), oRep:EndLine(), oRep:StartLine(), ;
                     oRep:Say(1, 'Total customers: '+Tran(nCounter, '@E 999,999'), 1),;
                     oRep:EndLine() )
 
it seems bullshit to me but I have not found solutions
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: nCounter Report not run ok

Post by cnavarro »

Please, use this

Code: Select all

     oReport:bStartRecord  := { || nCounter++ }
 
Remove nCounter++ of others lines or clauses
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Post by Silvio.Falconi »

cnavarro wrote:Please, use this

Code: Select all

     oReport:bStartRecord  := { || nCounter++ }
 
Remove nCounter++ of others lines or clauses
Error description: Error BASE/1005 Message not found: TREPORT:_BSTARTRECORD
Args:
[ 1] = O TREPORT

Stack Calls
===========
Called from: => __ERRRT_SBASE( 0 )
Called from: ../../../tobject.prg => TREPORT:ERROR( 0 )
Called from: ../../../tobject.prg => (b)HBOBJECT( 0 )
Called from: ../../../tobject.prg => TREPORT:MSGNOTFOUND( 0 )
Called from: ../../../tobject.prg => TREPORT:_BSTARTRECORD( 0 )
Called from: rep21.prg => REP21( 96 )
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: nCounter Report not run ok

Post by karinha »

João Santos - São Paulo - Brasil
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: nCounter Report not run ok

Post by cnavarro »

You are used

Code: Select all

     oRep:bStartRecord  := { || nCounter++ }
 
or oReport:bStartRecord ?
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Post by Silvio.Falconi »

cnavarro wrote:You are used

Code: Select all

     oRep:bStartRecord  := { || nCounter++ }
 
or oReport:bStartRecord ?
yes of course
but my question
for total customer we must use a local variable
for group command we need to use oRep:nCounter
Do you think about it.. is normal ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
carlos vargas
Posts: 1421
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: nCounter Report not run ok

Post by carlos vargas »

Silvio..

Code: Select all

oReport:aGroups[ nGroup ]:nCounter
 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
Post Reply