nCounter Report not run ok RESOLVED

Re: nCounter Report not run ok

Postby Silvio.Falconi » Fri Oct 09, 2020 6:57 pm

carlos vargas wrote:Silvio..
Code: Select all  Expand view

oReport:aGroups[ nGroup ]:nCounter
 


Carlos, I already knew,
the problem is:
1) For the command of the groups we must use
oReport: aGroups [nGroup]: nCounter

2) To get the total we can no longer use oReport: nCounter (because it makes a mistake) but we have to invent a local variable in our program to count the records, often when we have to print for a certain condition (bFor)

It wasn't like that before.
I don't remember right now but fw didn't have these problems
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: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok

Postby artu01 » Sat Oct 10, 2020 4:36 pm

Silvio.Falconi wrote:
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
   #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


Try this way

Code: Select all  Expand view

ncounter:=0


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

        ACTIVATE REPORT oRep ;
          ON endgroup (ncounter+=oRep:aGroups[1]:nCounter);
           ON END ( oRep:StartLine(), oRep:EndLine(), oRep:StartLine(), ;
                     oRep:Say(1, 'Total customers: '+Tran(nCounter, '@E 999,999'), 1),;
                     oRep:EndLine() )
 
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 » Sat Oct 10, 2020 5:03 pm

artu01 wrote:
Try this way


Dear artu01,
we allready resolved

For Groups
oReport:aGroups[ nGroup ]:nCounter

for bfor and others
local nCounter:= 0

...
oReport:bStartRecord := { || nCounter++ }

...
ACTIVATE REPORT oReport ;
....
oReport:Say(1, 'Total customers: '+Tran(nCounter, '@E 999,999'), 1)
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: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: nCounter Report not run ok RESOLVED

Postby artu01 » Sat Oct 10, 2020 6:30 pm

Excellent!
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

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

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