Print oBrowse aselected

Print oBrowse aselected

Postby Silvio.Falconi » Tue Apr 25, 2023 5: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

Image

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 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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Print oBrowse aselected

Postby nageswaragunupudi » Wed Apr 26, 2023 12:16 am

Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Print oBrowse aselected

Postby Silvio.Falconi » Wed Apr 26, 2023 7:30 am

nageswaragunupudi wrote:
Code: Select all  Expand view
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: Select all  Expand view
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

Image

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

Image

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: Select all  Expand view
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 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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Print oBrowse aselected

Postby nageswaragunupudi » Wed Apr 26, 2023 8: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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Print oBrowse aselected

Postby Silvio.Falconi » Wed Apr 26, 2023 8: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 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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Print oBrowse aselected

Postby nageswaragunupudi » Wed Apr 26, 2023 5:46 pm

Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 100 guests