nCounter Report not run ok RESOLVED

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

Re: nCounter Report not run ok

Post by Silvio.Falconi »

carlos vargas wrote:Silvio..

Code: Select all

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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
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:
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
Try this way

Code: Select all

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
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:
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)
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
artu01
Posts: 306
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: nCounter Report not run ok RESOLVED

Post by artu01 »

Excellent!
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
Post Reply