nCounter Report not run ok RESOLVED

nCounter Report not run ok RESOLVED

Postby Silvio.Falconi » Thu Oct 08, 2020 9:16 am

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  Expand view  RUN


#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  Expand view  RUN
local nCounter := 1


and then
Code: Select all  Expand view  RUN

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.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Postby nageswaragunupudi » Thu Oct 08, 2020 1:39 pm

We will look into this
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: nCounter Report not run ok

Postby FranciscoA » Thu Oct 08, 2020 3: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
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: nCounter Report not run ok

Postby James Bott » Thu Oct 08, 2020 4: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: nCounter Report not run ok

Postby artu01 » Thu Oct 08, 2020 5:17 pm

Silvio.Falconi wrote:Dear Antonio,

IF I made ( I saw a Nages topic)

Code: Select all  Expand view  RUN
local nCounter := 1


and then
Code: Select all  Expand view  RUN

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
artu01
 
Posts: 400
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: nCounter Report not run ok

Postby Silvio.Falconi » Thu Oct 08, 2020 5: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Postby Silvio.Falconi » Thu Oct 08, 2020 6: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: Select all  Expand view  RUN
   #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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Postby Silvio.Falconi » Thu Oct 08, 2020 6: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: Select all  Expand view  RUN

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Postby Silvio.Falconi » Thu Oct 08, 2020 7:01 pm

OK PERHAPS WE CAN RESOLVED IT

for the Group command we can use the nCounter of Report class
Code: Select all  Expand view  RUN

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  Expand view  RUN
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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Postby cnavarro » Thu Oct 08, 2020 10:59 pm

Please, use this
Code: Select all  Expand view  RUN

     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
User avatar
cnavarro
 
Posts: 6552
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: nCounter Report not run ok

Postby Silvio.Falconi » Fri Oct 09, 2020 7:15 am

cnavarro wrote:Please, use this
Code: Select all  Expand view  RUN

     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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Postby karinha » Fri Oct 09, 2020 11:45 am

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: nCounter Report not run ok

Postby cnavarro » Fri Oct 09, 2020 11:47 am

You are used
Code: Select all  Expand view  RUN

     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
User avatar
cnavarro
 
Posts: 6552
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: nCounter Report not run ok

Postby Silvio.Falconi » Fri Oct 09, 2020 3:47 pm

cnavarro wrote:You are used
Code: Select all  Expand view  RUN

     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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Postby carlos vargas » Fri Oct 09, 2020 4:03 pm

Silvio..
Code: Select all  Expand view  RUN

oReport:aGroups[ nGroup ]:nCounter
 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1721
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 73 guests