FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Print oBrowse aselected
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Print oBrowse aselected
Posted: Tue Apr 25, 2023 05:28 PM
I wish print some record with Tprinter class NO Report class
these records are selected from a xbrowse as you can see here



If I make oBrowse:aselected I have only numbers no record

as I make to print each columns of xbrowse but only the records selected ?

do i have to create an array?

now the example has only 4 fields but when I have many more fields building an array would become unnerving, is there a better method?
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: Print oBrowse aselected
Posted: Wed Apr 26, 2023 12:16 AM
Code (fw): Select all Collapse
cAlias   := oBrw:cAlias
nAt      := 1
nSaveRec := ( cAlias )->( RECNO() )

//
//

do while nAt <= Len( oBrw:aSelected )
   ( cAlias )->( DBGOTO( oBrw:aSelected[ nAt ] ) )
   // PRINT (cAlias)->fields the way you want 
   nAt++
enddo
( cAlias )->( DBGOTO( nSaveRec ) )
Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Print oBrowse aselected
Posted: Wed Apr 26, 2023 07:30 AM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
cAlias   := oBrw:cAlias
nAt      := 1
nSaveRec := ( cAlias )->( RECNO() )

//
//

do while nAt <= oBrw:aSelected
   ( cAlias )->( DBGOTO( oBrw:aSelected( nAt ) ) )
   // PRINT (cAlias)->fields the way you want 
   nAt++
enddo
( cAlias )->( DBGOTO( nSaveRec ) )



I tried but give me error
Code (fw): Select all Collapse
 Error description: Error BASE/1074  Argument error: <=
   Args:
     [   1] = N   1
     [   2] = A   {5,6} length: 2

Stack Calls
===========
   Called from: source\Pcomuni.prg => PRINT_BROWSE_COMUNI( 447 )


I explain you

From xBrowse I press Stampa button



The I press this button the procedure open a dialog with options of Print , so I can select also the columns to print



then it retun to dialog "options of Print" and then I can print the browse

here the function I use to print the browse

Code (fw): Select all Collapse
Function Print_Browse_Comuni(oBrowse,lPrv,lLandscape)
local oPrn, oFn1, oFn2, oFn3, nRec, cSTit, nPre:=0
local aDes, aHas, nHor, nVer, nRow:=5.5, cForm
loca cFont:="Arial"
local lSelected

local cAlias   := oBrowse:cAlias
local nAt      := 1
local nSaveRec := ( cAlias )->( RECNO() )

    IF len( oBrowse:aSelected) <1
       lSelected:=.f.
    Endif



      oPrn:=PrintBegin("Comuni",.F.,lPrv,,.T.)
      DEFINE FONT oFn1 NAME cFont SIZE 0,- 8      OF oPrn
      DEFINE FONT oFn2 NAME cFont SIZE 0,- 8 BOLD OF oPrn
      DEFINE FONT oFn3 NAME cFont SIZE 0,-11 BOLD OF oPrn
      cSTit:="Comuni"
      cForm:="" 
      oPrn:lPrvModal:=.T.
      IF(!lLandscape,oPrn:SetPortrait(),oPrn:SetLandScape())
      nHor:=oPrn:nHorzSize()
      nVer:=oPrn:nVertSize()
      CursorWait()
      PageBegin()

       // Title_WIN(oPrn,nHor,nVer,oFn1,oFn2,oFn3,cSTit,1,.F.,cForm)

         oPrn:CmSay(4.7, 2.5,"CAP",oFn1)
         oPrn:CmSay(4.7,12.0,"CITTA'"     ,oFn1,,,,2)
         oPrn:CmSay(4.7,14.5,"PROVINCIA"  ,oFn1,,,,1)


    IF lSelected
           do while  nAt <= oBrowse:aSelected
                 ( cAlias )->( DBGOTO(  oBrowse:aSelected( nAt ) ) )
                 // PRINT (cAlias)->fields the way you want
                 oPrn:CmSay(nRow, 2.5,  (cAlias)->Cap,oFn1,9.0)
                 oPrn:CmSay(nRow,12.0,  (cAlias)->comune,oFn1,,,,2)
                 oPrn:CmSay(nRow,14.5,  (cAlias)->prov,oFn1,,,,1)
                  nRow+=0.4
                  nPre++
              IF nRow>=25.5
               PageEnd()
               PageBegin()
                    //Title_WIN(oPrn,nHor,nVer,oFn1,oFn2,oFn3,cSTit,1,.F.,cForm)
                    oPrn:CmSay(4.7, 2.5,"CAP",oFn1)
                    oPrn:CmSay(4.7,12.0,"CITTA'"     ,oFn1,,,,2)
                    oPrn:CmSay(4.7,14.5,"PROVINCIA"  ,oFn1,,,,1)
                    nRow:=5.5
               ENDIF
            nAt++
         enddo

         ( cAlias )->( DBGOTO( nSaveRec ) )

      ELSE

      do while ! ( cAlias )->( eof())
                 oPrn:CmSay(nRow, 2.5,  (cAlias)->Cap,oFn1,9.0)
                 oPrn:CmSay(nRow,12.0,  (cAlias)->comune,oFn1,,,,2)
                 oPrn:CmSay(nRow,14.5,  (cAlias)->prov,oFn1,,,,1)
                  nRow+=0.4
                  nPre++
              IF nRow>=25.5
               PageEnd()
               PageBegin()
                   // Title_WIN(oPrn,nHor,nVer,oFn1,oFn2,oFn3,cSTit,1,.F.,cForm)
                    oPrn:CmSay(4.7, 2.5,"CAP",oFn1)
                    oPrn:CmSay(4.7,12.0,"CITTA'"     ,oFn1,,,,2)
                    oPrn:CmSay(4.7,14.5,"PROVINCIA"  ,oFn1,,,,1)
                    nRow:=5.5
               ENDIF
            ( cAlias )->( dbskip())
         enddo

     Endif



         aDes:=oPrn:Cmtr2Pix(nRow+0.4, 1.5)
         aHas:=oPrn:Cmtr2Pix(nRow+0.4,19.5)
         oPrn:Line(aDes[1],aDes[2],aHas[1],aHas[2])
         oPrn:CmSay(nRow+=0.5,10.5,Tran(nPre,"9,999")+"  Comune(i)",oFn1,,,,2)
         aDes:=oPrn:Cmtr2Pix(nRow+0.4, 1.5)
         aHas:=oPrn:Cmtr2Pix(nRow+0.4,19.5)
         oPrn:Line(aDes[1],aDes[2],aHas[1],aHas[2])
      PageEnd()
      oFn1:End(); oFn2:End(); oFn3:End()
   PrintEnd()



return nil
I saw cAlias is Empty

Notice the final use can select one or more record but it can no select none...
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: Print oBrowse aselected
Posted: Wed Apr 26, 2023 08:16 AM

What is the source of your browse? Array or DBF or whatelse?

My solution is an example that works with DBF.

If not DBF, you should understand the logic and apply to your case.

Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Print oBrowse aselected
Posted: Wed Apr 26, 2023 08:19 AM
nageswaragunupudi wrote:What is the source of your browse? Array or DBF or whatelse?

My solution is an example that works with DBF.
If not DBF, you should understand the logic and apply to your case.
SEE your mail


I use Tdatabase
oDbf:=TComuni():New()
oDbf:setorder(1)
oDbf:Gotop()

local aCols := { ;
{ "COMUNE", "Comune" ,, 120, },;
{ "PROV", "Provincia",, 70, },;
{ "CAP", "Cap" ,, 50, },;
{ "CODREG", "Regione" ,, 80, } }


@ 110,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
DATASOURCE oDbf COLUMNS aCols ;
AUTOSORT FONT oFont;
NOBORDER CELL LINES
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: Print oBrowse aselected
Posted: Wed Apr 26, 2023 05:46 PM
Code (fw): Select all Collapse
oDbf     := oBrw:oDbf
nAt      := 1
nSaveRec := oDbf:RecNo()

//
//

do while nAt <= Len( oBrw:aSelected )
   oDbf:GoTo( oBrw:aSelected[ nAt ] )
   // PRINT oDbf:Fields the way you want
   nAt++
enddo
oDbf:GoTo( nSaveRec )
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion