FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Calculate total pages
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Calculate total pages
Posted: Mon Nov 27, 2023 05:29 PM
Mr. Silvio

Please make only this one change in the report.prg:
In the Method Activate(), locate these lines:
Code (fw): Select all Collapse
      if !::lHaru .and. Empty( ::oDevice:cFile ) .and. !PrintQueue()
         Eval( ::bPreview, ::oDevice )
      else
         PrintEnd()
      endif
Delete all these lines and substitute only one line:
Code (fw): Select all Collapse
   PrintEnd()
Then test your code.

I tested with this code and it is working fine:
You may also try this code first as it is and then use it in your programs
Code (fw): Select all Collapse
function TestReport()

   local oRep, oFont
   local nLine := 0

   USE CUSTOMER NEW SHARED
   GO TOP

   DEFINE FONT oFont NAME "TAHOMA"  SIZE 0,-12

   REPORT oRep FONT oFont PREVIEW  ;
      TITLE "CUSTOMER" ;
      FOOTER FWString( "Page" ) + " : " + cValToChar( oRep:oDevice:nPage ) + "/" + ;
      oRep:oDevice:cLastPage ;
      CENTER

   COLUMN TITLE "LINE"   DATA nLine          FONT 1 SIZE 4
   COLUMN TITLE "NAME"   DATA FIELD->FIRST   FONT 1 SIZE 15
   COLUMN TITLE "SURNAME" DATA FIELD->LAST   FONT 1 RIGHT SIZE 15
   COLUMN TITLE "CITY"   DATA FIELD->CITY    FONT 1 CENTER SIZE 15
   COLUMN TITLE "STATE"  DATA FIELD->STATE   FONT 1 CENTER
   COLUMN TITLE "SALARY" DATA FIELD->SALARY  PICTURE "$ 9,999,999.99";
      FONT 1 TOTAL  SIZE 14

   ENDREPORT

   oRep:bInit        := { || nLine := 0 }
   oRep:bStartRecord := { || nLine++ }

   ACTIVATE REPORT oRep

   RELEASE FONT oFont

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Calculate total pages
Posted: Mon Nov 27, 2023 05:32 PM
In XBrowse.prg
Please make this change in METHOD Report(...)
Replace these lines
Code (fw): Select all Collapse
   REPORT oRep TITLE cTitle ;
          FOOTER FWString( "Page" ) + " : " + cValToChar( oRep:nPage ) CENTER ;
          FONT oFont,oBold ;
          TO DEVICE oPrn
with
Code (fw): Select all Collapse
   REPORT oRep TITLE cTitle ;
          FOOTER FWString( "Page" ) + " : " + cValToChar( oPrn:nPage ) ;
               + "/" + oPrn:cLastPage CENTER ;
          FONT oFont,oBold ;
          TO DEVICE oPrn
Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Calculate total pages
Posted: Tue Nov 28, 2023 08:39 AM

thanks Rao

Would this also work if I use the browse setup?

example

oBrw:Report( cTitle, , , ;

     { |oRep, oBrw| MySetUp( oRep, oBrw, oDbf,aGroup,nGroup,lEject,aCampi ) } )

static function MySetUp( oRep, oBrw, oDbf,aGroup,nGroup,lEject,afields )

local cFooter := "Progetto Magazzino - "

local cTitle1 := "title row 1"

local cTitle2 := "title row 2"

local nTotalpages:= oRep:oDevice:cLastPage

oRep:oTitle := TrLine():New( {{|| cf(date())+"- Pagina : "+Str(oRep:nPage,3)+"/"+(nTotalpages)} }, oRep, 2 )

I tried and run ok

thanks Rao

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

Continue the discussion