FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour nCounter Report not run ok RESOLVED
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
nCounter Report not run ok RESOLVED
Posted: Thu Oct 08, 2020 09:16 AM
Dear Antonio,

if I made

GROUP ON CU->STATE ;
FOOTER " » Total FOR STATE » "+::aGroups[1]:cValue +"("+ltrim(str(::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



why ?



here the test (rep21.prg)

Code (fw): Select all Collapse
#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 (fw): Select all Collapse
 local nCounter := 1


and then
Code (fw): Select all Collapse
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 ?




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

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: nCounter Report not run ok
Posted: Thu Oct 08, 2020 01:39 PM

We will look into this

Regards



G. N. Rao.

Hyderabad, India
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: nCounter Report not run ok
Posted: Thu Oct 08, 2020 03:50 PM

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.



Fwxh-MySql-TMySql
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: nCounter Report not run ok
Posted: Thu Oct 08, 2020 04:51 PM

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
Posts: 400
Joined: Fri May 11, 2007 08:20 PM
Re: nCounter Report not run ok
Posted: Thu Oct 08, 2020 05:17 PM
Silvio.Falconi wrote:Dear Antonio,

IF I made ( I saw a Nages topic)

Code (fw): Select all Collapse
 local nCounter := 1


and then
Code (fw): Select all Collapse
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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: nCounter Report not run ok
Posted: Thu Oct 08, 2020 05:34 PM

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

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: nCounter Report not run ok
Posted: Thu Oct 08, 2020 06:24 PM
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/viewtopic.php?f=3&t=20817&p=110839&hilit=ncounter#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 (fw): Select all Collapse
    #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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: nCounter Report not run ok
Posted: Thu Oct 08, 2020 06:43 PM
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 (fw): Select all Collapse
 
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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: nCounter Report not run ok
Posted: Thu Oct 08, 2020 07:01 PM
OK PERHAPS WE CAN RESOLVED IT

for the Group command we can use the nCounter of Report class
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: nCounter Report not run ok
Posted: Thu Oct 08, 2020 10:59 PM
Please, use this
Code (fw): Select all Collapse
     oReport:bStartRecord  := { || nCounter++ }

Remove nCounter++ of others lines or clauses
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: nCounter Report not run ok
Posted: Fri Oct 09, 2020 07:15 AM
cnavarro wrote:Please, use this
Code (fw): Select all Collapse
     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 )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: nCounter Report not run ok
Posted: Fri Oct 09, 2020 11:45 AM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: nCounter Report not run ok
Posted: Fri Oct 09, 2020 11:47 AM
You are used
Code (fw): Select all Collapse
     oRep:bStartRecord  := { || nCounter++ }


or oReport:bStartRecord ?
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: nCounter Report not run ok
Posted: Fri Oct 09, 2020 03:47 PM
cnavarro wrote:You are used
Code (fw): Select all Collapse
     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 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: nCounter Report not run ok
Posted: Fri Oct 09, 2020 04:03 PM
Silvio..
Code (fw): Select all Collapse
oReport:aGroups[ nGroup ]:nCounter
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)