Page 1 of 1

TPrinter Sample

Posted: Wed Oct 21, 2009 10:47 am
by sajith
Can some share a sample program using T Printer

Regards,
sajith

Re: TPrinter Sample

Posted: Thu Oct 22, 2009 10:30 pm
by Colin Haig
static function SumDebt(oInvc,oCode,oRepDlg,oPay,oCrInv)
local aDates := array(6,2),aValues := array(6),oPrn,nPage := 0,oFont,oFont1,wRow := 0,;
nTopRow := 0,nRd := 0,nCd := 0,nCd1 := 0,lScreen := FALSE ,cTitle := '',;
nBalance := 0,cCode := '',nClCurr := 0,nCl30 := 0,nCl60 := 0,nCl90 := 0,nClOver := 0,;
nClRet := 0,nClTotal := 0,cName := '',nTotCurr := 0,nTot30 := 0,nTot60 := 0,;
nTot90 := 0,nTotOver := 0,nTotRet := 0,nTotTot := 0,;
aGetDates := array(2),aPrevDates := array(6,2),lDate := FALSE

cTitle := ''Aged Summary Debtors Ledger"
if PrntBox(@lScreen,'Print Options For Summary Debtors') // Dialog to allow user to select screen , printer . select printer or cancel

if lScreen
print oPrn title cTitle PREVIEW
else
print oPrn title cTitle
endif
define font oFont name "Courier New" size 0,-12 of oPrn
define font oFont1 name "Courier New" size 0,-10 of oPrn
oFont:Activate(oPrn:hDC)
oFont1:Activate(oPrn:hDC)
nRd := oPrn:nLogPixelY/6
nCd := oPrn:nLogPixelX/10
nCd1 := oPrn:nLogPixelX/15
lDate := FALSE
oInvc:Select()
oInvc:SetOrder('CODE')
oInvc:Top()
cCode := oInvc:code
CalcDays(aDates) // for aging of accounts
do while ! oInvc:eof
nClCurr := 0
nCl30 := 0
nCl60 := 0
nCl90 := 0
nClOver := 0
nClRet := 0
nClTotal := 0
do while oInvc:code == cCode .and. ! oInvc:eof()
cName := oCode:client
DebitHeader(@nPage,oPrn,@nTopRow,@wRow,oFont,nRd,nCd,nCd1,cTitle,oFont1,lDate,aDates)
nBalance := oInvc:invtot - (oInvc:invpaid + oInvc:invcred + oInvc:invret)
NewCalc(aDates,oInvc:invdt,aValues,nBalance,oInvc:invret)
nClCurr+= aValues[1]
nCl30+= aValues[2]
nCl60+= aValues[3]
nCl90+= aValues[4]
nClOver+= aValues[5]
nClRet+= aValues[6]
oInvc:skip()
enddo
SysRefresh()
nClTotal := nClCurr + nCl30 + nCl60 + nCl90 + nClOver + nClRet
nTotCurr+= nClCurr
nTot30+= nCl30
nTot60+= nCl60
nTot90+= nCl90
nTotOver+= nClOver
oPrn:Say(wprow(@wrow,1) * nRd,0 * nCd1,left(cName,25),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,31 * nCd1,str(nClCurr,9,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,45 * nCd1,str(nCl30,9,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,59 * nCd1,str(nCl60,9,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,71 * nCd1,str(nCl90,9,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,83 * nCd1,str(nClOver,9,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,96 * nCd1,str(nClTotal,9,2),oFont1)
cCode := oInvc:code
enddo
nTotTot := nTotCurr + nTot30 + nTot60 + nTot90 + nTotOver + nTotRet
oPrn:Say(wprow(@wrow,1) * nRd,0 * nCd1,replicate('-',105),oFont1)
oPrn:Say(wprow(@wrow,1) * nRd,30 * nCd1,str(nTotCurr,10,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,44 * nCd1,str(nTot30,10,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,58 * nCd1,str(nTot60,10,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,70 * nCd1,str(nTot90,10,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,82 * nCd1,str(nTotOver,10,2),oFont1)
oPrn:Say(wprow(@wrow,0) * nRd,95 * nCd1,str(nTotTot,10,2),oFont1)
oPrn:Say(wprow(@wrow,1) * nRd,0 * nCd1,replicate('-',105),oFont1)
endpage
endprint
oFont:end()
oFont1:end()
endif
return nil
//-----------------------------------------------------------------------------//
static function DebitHeader(nPage,oPrn,nTopRow,wRow,oFont,nRd,nCd,nCd1,cTitle,oFont1,lDate,aDates)
local nLen := len(cTitle)
if nPage == 0 .or. wrow >= 62
nPage++
if nPage > 1 .and. wrow >= 62
wrow := 0
oPrn:EndPage()
nTopRow := 0
endif
oPrn:StartPage()
oPrn:Say(nTopRow * nRd,(40 - (nLen/2)) * nCd,cTitle,oFont)
oPrn:Say((nTopRow + 1)* nRd,(40 - (nLen/2))*nCd,replicate('-',nLen),oFont)
oPrn:Say((nTopRow + 2)* nRd,2 * nCd,'',oFont)
oPrn:Say((nTopRow + 3)* nRd,2 * nCd,'Date : ' + dtoc(date()),oFont)
oPrn:Say((nTopRow + 3)* nRd,60 * nCd,'Page No : ' + str(nPage,2),oFont)
oPrn:Say((nTopRow + 5)* nRd,2 * nCd,'Current Month - ' + cmonth(aDates[1,1]),oFont)
oPrn:Say((nTopRow + 7)* nRd,0 * nCd1,'Debtor',oFont1)
if ! lDate
oPrn:Say((nTopRow + 7)* nRd,33 * nCd1,'Current',oFont1)
oPrn:Say((nTopRow + 7)* nRd,47 * nCd1,'30Days',oFont1)
oPrn:Say((nTopRow + 7)* nRd,61 * nCd1,'60Days',oFont1)
oPrn:Say((nTopRow + 7)* nRd,73 * nCd1,'90Days',oFont1)
oPrn:Say((nTopRow + 7)* nRd,88 * nCd1,'Over',oFont1)
oPrn:Say((nTopRow + 7)* nRd,101 * nCd1,'Total',oFont1)
else
oPrn:Say((nTopRow + 7)* nRd,33 * nCd1,substr(cMonth(aDates[1,1]),1,3),oFont1)
oPrn:Say((nTopRow + 7)* nRd,47 * nCd1,substr(cMonth(aDates[2,1]),1,3),oFont1)
oPrn:Say((nTopRow + 7)* nRd,61 * nCd1,substr(cMonth(aDates[3,1]),1,3),oFont1)
oPrn:Say((nTopRow + 7)* nRd,73 * nCd1,substr(cmonth(aDates[4,1]),1,3),oFont1)
oPrn:Say((nTopRow + 7)* nRd,88 * nCd1,'Over',oFont1)
oPrn:Say((nTopRow + 7)* nRd,101 * nCd1,'Total',oFont1)
endif
oPrn:Say((nTopRow + 8)* nRd,0 * nCd1,'======',oFont1)
oPrn:Say((nTopRow + 8)* nRd,33 * nCd1,'=======',oFont1)
oPrn:Say((nTopRow + 8)* nRd,47 * nCd1,'=======',oFont1)
oPrn:Say((nTopRow + 8)* nRd,61 * nCd1,'=======',oFont1)
oPrn:Say((nTopRow + 8)* nRd,73 * nCd1,'=======',oFont1)
oPrn:Say((nTopRow + 8)* nRd,88 * nCd1,'====',oFont1)
oPrn:Say((nTopRow + 8)* nRd,101 * nCd1,'=====',oFont1)
wrow := 8
endif
return(nil)
//-----------------------------------------------------------------------------//
function wprow(nRow,nMove)
return(nRow+=nMove)
//-----------------------------------------------------------------------------//

Hope this helps

Colin

Re: TPrinter Sample

Posted: Sat Oct 24, 2009 6:27 am
by sajith
Dear Colin,ManyMany thanks for ur Support.