jose hilton Posted November 4, 2005 Report Share Posted November 4, 2005 Boa tarde pessoal a) Se alguem poder mim responder porque que eu alguns micros esse comando nao funciona e em outros sim. Como faco para condenca a impressao em HP Grato Hilton Jose Hilton FWH 2.6 function LISTAR(olbx) ******************************* lin:=1 Col:=0 npage:=1 latoo := .t. DBSELECTAREA("CUPOM") GO TOP if ! oPrn:isprinter() msginfo("Verifique a Impressora") endif usinf:=alltrim("PLANETA BELEZA") cFile:="REPORT.PRN" //  melhor imprimir primeiro para arquivo. oPrn:=TDosPrn():New(cFile) // Isto evita nÆo concluir a impressÆo. oPrn:StartPage() oPrn:Say(lin,Col+10,chr(27)+chr(31)+chr(48)+chr(15)+'0'+usinf) lin++ oPrn:Say(lin,col+8,dtoc(date())+' - '+time()) lin++ oPrn:Say(lin,col+11,"Cupom: "+strzero(xcupom,6,0)) lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,col,"CONTROLE INTERNO, NAO E CUPOM FISCAL !!") lin++ oPrn:Say(lin,col," Comprovante para retirada de produtos") lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,Col,"Item Codigo --Descricao do Produto --") lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oitem:=1 wvalto:=0 wdesct:=0 wdemon:=0 do while !eof() wde1=len(alltrim(CUPOM->descricAO)) wde2=alltrim(substr(CUPOM->descricAO,1,26))+repli('.',26-wde1) oPrn:Say(lin,Col,cupom->produto+' '+wde2) lin++ oPrn:Say(lin,Col+03,'R$ '+transform(CUPOM->PRECO,"@e 9,999.99")+' x '+transform(CUPOM->quantidADE,"@e 999.999")+' = '+str(CUPOM->PRECO*CUPOM->QUANTIDADE,9,2)) lin++ wvalto:=wvalto+(CUPOM->PRECO*CUPOM->QUANTIDADE) wdesct:=wdesct+0 wdemon:=wvalto+wdesct skip oitem++ if lin>60 oPrn:Say(lin,Col,"----------------------------------------") lin:=1 npage=npage+1 endif enddo oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,Col+5,'Total Bruto R$ '+transform(wdemon,"@e 9,999.99")) lin++ oPrn:Say(lin,Col+5,'Descontos (-) R$ '+transform(wdesct,"@e 9,999.99")) lin++ oPrn:Say(lin,Col+5,'Total Final '+alltrim(str(oitem,4)) +" "+transform(wdemon-wdesct,"@e 9,999.99")) lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,col," EMITA A NOTA FISCAL REGULARMENTE ") lin++ oPrn:Say(lin,col," ATENCAO! NAO E COMPROVANTE FISCAL") lin++ tpvn := 0 if tpvn=6 oPrn:Say(lin,Col,'Confirmo a aquisicao dos produtos acima especi-') lin++ oPrn:Say(lin,Col,'ficados com vencimento previsto para '+dtoc(wvenc)) lin=lin+3 oPrn:Say(lin,Col,repli('_',48)) lin=lin+3 endif //oPrn:Say(lin,Col,strzero(tpvn,2)+' ('+alltrim(wnome)+'/'+alltrim(usnom)+')') oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:EndPage() // Obrigat¢rio oPrn:End(draftmode()) // Idem SysRefresh() return .t. CLASS TDosPrn DATA LastError DATA cPort, cCompress, cNormal, cFormFeed, cBuffer DATA hDC, lin, nCol, nLeftMargin, nTopMargin DATA lAnsiToOem,lCompress DATA lZeraBuffer // By Gilmer www.fivewin.com.br DATA oWnd, oPagina // Ednaldo DATA nPage AS NUMERIC // Ednaldo METHOD New(cPort) CONSTRUCTOR METHOD End() // Antigo(Old) // METHOD StartPage() VIRTUAL // NÆo Conta as P ginas // METHOD EndPage() // Novo (New) // Conta as P ginas By Ednaldo Rolim METHOD StartPage() INLINE ::ShowProc() // Ednaldo METHOD EndPage() // METHOD Command(xPar1, xPar2, xPar3, xPar4, xPar5) //velho METHOD Command(cStr1, cStr2, cStr3, cStr4, cStr5) // novo METHOD SetCoors(lin, nCol) METHOD NewLine() INLINE (::cBuffer += CRLF ,; ::lin++ ,; ::nCol := 0 ) METHOD Write(cText, lAToO) ; INLINE (iif(lAtoO == NIL, lAtoO := .T.,),; ::cBuffer += iif(lAtoO, AnsitoOem(cText), cText) ,; ::nCol += len(cText) ) METHOD Say(lin, nCol, cText, lAToO) METHOD SayCmp(lin, nCol, cText) METHOD CharSay(lin,nCol,cText) INLINE (IIf(::lCompress,; ::SayCmp(lin,nCol,cText),; ::Say(lin,nCol,cText))) METHOD ZeraBuffer() // By. Gilmer METHOD PrintFile(cFile) METHOD ShowProc() // Ednaldo ENDCLASS //----------------------------------------------------------------------------// METHOD New(cPort, lFile, lCompress) CLASS TDosPrn DEFAULT cPort := "LPT1" ,; lFile := .T. ,; lCompress := .f. cPort := Upper(cPort) ::cCompress := "15" ::cNormal := "18" ::cFormFeed := "12" ::cBuffer := "" ::nLeftMargin := 0 ::nTopMargin := 0 ::lin := 0 ::nCol := 0 ::lAnsiToOem := .T. ::cPort := cPort + iif(!"." $ cPort, ".PRN", "") ::hDC := fCreate(::cPort) ::LastError := 0 // By. Gilmer // .F. Pula P gina, .T. NÆo Pula a P gina (Cupom Fiscal) ::lZeraBuffer:=.T. IF ::hDC < 0 ::LastError := fError() ENDIF ::nPage := 1 // Ednaldo ::ShowProc() // Ednaldo RETURN Self //----------------------------------------------------------------------------// METHOD End() CLASS TDosPrn IF !empty(::lin+::nCol) ::EndPage() ENDIF ::LastError := 0 IF !fClose(::hDC) ::LastError := fError() ENDIF CursorArrow() if ::oWnd != Nil // Ednaldo ::oWnd:End() // Ednaldo endif // Ednaldo RETURN NIL //----------------------------------------------------------------------------// METHOD EndPage() CLASS TDosPrn LOCAL nFor, nLen, nSec LOCAL lError If !::lZeraBuffer // By Gilmer ::Command(::cFormFeed) End ::LastError := 0 IF fWrite(::hDC, ::cBuffer) < len(::cBuffer) ::LastError := fError() ENDIF ::cBuffer := "" ::lin := 0 ::nCol := 0 RETURN NIL //----------------------------------------------------------------------------// //METHOD Command(xPar1, xPar2, xPar3, xPar4, xPar5) CLASS TDosPrn // Velho METHOD Command(cStr1, cStr2, cStr3, cStr4, cStr5) CLASS TDosPrn // Novo LOCAL cCommand, cToken, cString LOCAL nToken //cString := cValToChar(xPar1) // Velho cString := cStr1 // Novo /* // Velho IF xPar2 != NIL cString += ","+cValToChar(xPar2) ENDIF */ IF cStr2 != NIL cString += ","+cStr2 ENDIF /* // Velho IF xPar3 != NIL cString += ","+cValToChar(xPar3) ENDIF */ IF cStr3 != NIL cString += ","+cStr3 ENDIF /* // Velho IF xPar4 != NIL cString += ","+cValToChar(xPar4) ENDIF */ IF cStr4 != NIL cString += ","+cStr4 ENDIF /* // Velho IF xPar5 != NIL cString += ","+cValToChar(xPar5) ENDIF */ IF cStr5 != NIL cString += ","+cStr5 ENDIF cCommand := "" nToken := 1 DO WHILE !Empty(cToken := StrToken(cString, nToken++, ",")) cCommand += Chr(Val(cToken)) ENDDO ::cBuffer += cCommand RETURN NIL //----------------------------------------------------------------------------// METHOD SetCoors(lin, nCol) CLASS TDosPrn lin += ::nTopMargin nCol += ::nLeftMargin IF ::lin > lin ::EndPage() ::nPage++ // Ednaldo ::StartPage() ENDIF /* // do Site IF ::lin > lin ::EndPage() ::StartPage() ENDIF */ IF lin == ::lin .AND. nCol < ::nCol ::EndPage() ::nPage++ // Ednaldo ::StartPage() ENDIF /* // do Site IF lin == ::lin .AND. nCol < ::nCol ::EndPage() ::StartPage() ENDIF */ DO WHILE ::lin < lin ::NewLine() ENDDO IF nCol > ::nCol ::Write(Space(nCol-::nCol)) ENDIF // By. Gilmer If Len(::cBuffer)>=7928 ::ZeraBuffer() End RETURN NIL //----------------------------------------------------------------------------// METHOD Say(lin, nCol, cText, lAToO) CLASS TDosPrn DEFAULT lAToO := ::lAnsiToOem IF VALTYPE( cText ) = "D" cText := DTOC( cText ) ENDIF IF VALTYPE( cText ) = "N" cText := STR( cText ) ENDIF ::SetCoors(lin, nCol) ::Write(cText, lAToO) RETURN NIL //----------------------------------------------------------------------------// METHOD SayCmp(lin, nCol, cText, lAToO) CLASS TDosPrn DEFAULT lAToO := ::lAnsiToOem ::Command(::cCompress) ::SetCoors(lin, nCol) ::cBuffer += iif(lAToO, AnsitoOem(cText), cText) ::nCol += Int(len(cText)) * by Digao ::nCol += Int(len(cText)/1.7+.5) ::Command(::cNormal) RETURN NIL //----------------------------------------------------------------------------// METHOD ZeraBuffer() CLASS TDosPrn ::LastError := 0 If ::lZeraBuffer IF fWrite(::hDC, ::cBuffer) < len(::cBuffer) ::LastError := fError() ENDIF ::cBuffer := "" End RETURN NIL //----------------------------------------------------------------------------// FUNCTION WorkSheet(cPort) LOCAL oPrn LOCAL cLine LOCAL nFor cLine := "" FOR nFor := 0 TO 7 cLine += Str(nFor,1)+Replicate(".",9) NEXT cLine := Substr(cLine,3) oPrn := TDosPrn():New(cPort) oPrn:StartPage() FOR nFor := 0 TO 65 oPrn:Say(nFor,0,StrZero(nFor,2)+cLine) NEXT oPrn:EndPage() oPrn:End() RETURN NIL //----------------------------------------------------------------------------// METHOD PrintFile(cFile) CLASS TDosPrn LOCAL hFile LOCAL nRead LOCAL cBuffer hFile := FOpen(cFile, FO_READ) IF hFile < 0 RETURN .F. ENDIF cBuffer := Space(PF_BUFLEN) DO nRead := fRead(hFile, @cBuffer, PF_BUFLEN) IF fWrite(::hDC, Left(cBuffer, nRead)) < nRead ::LastError := fError() fClose(hFile) RETURN .F. ENDIF UNTIL nRead == PF_BUFLEN fClose(hFile) RETURN .T. //----------------------------------------------------------------------------// // Visualiza Processo de impressao // Ednaldo //----------------------------------------------------------------------------// METHOD ShowProc() CLASS TDosPrn IF ::oWnd = Nil DEFINE DIALOG ::oWnd TITLE "Imprimindo ..." ; FROM 230, 217 TO 360, 575 PIXEL ; COLORS CLBLACK, nRGB(193,205,205) @ 10, 08 TO 40, 172 OF ::oWnd PIXEL @ 1.4, 2 ICON NAME "PRINT.ICO" OF ::oWnd @ 25, 35 SAY "Imprimindo Página :" ; PIXEL OF ::oWnd SIZE 70, 12 RIGHT @ 25, 107 SAY ::oPagina VAR ::nPage ; PIXEL OF ::oWnd UPDATE SIZE 15, 12 RIGHT @ 47, 60 BUTTON "Aguarde..." SIZE 60, 12 ; PIXEL OF ::oWnd ACTION .t. ::oWnd:bPainted := {|| iif(::nPage>0, ::oPagina:Refresh(), )} ACTIVATE DIALOG ::oWnd CENTER NOWAIT CursorWait() SysRefresh() ELSE ::oWnd:BeginPaint() ::oWnd:Paint() ::oWnd:EndPaint() ENDIF RETURN NIL Quote Link to comment Share on other sites More sharing options...
jose hilton Posted November 4, 2005 Author Report Share Posted November 4, 2005 Boa tarde pessoal a) Se alguem poder mim responder porque que eu alguns micros esse comando nao funciona e em outros sim. Como faco para condenca a impressao em HP Grato Hilton Jose Hilton FWH 2.6 function LISTAR(olbx) ******************************* lin:=1 Col:=0 npage:=1 latoo := .t. DBSELECTAREA("CUPOM") GO TOP if ! oPrn:isprinter() msginfo("Verifique a Impressora") endif usinf:=alltrim("PLANETA BELEZA") cFile:="REPORT.PRN" //  melhor imprimir primeiro para arquivo. oPrn:=TDosPrn():New(cFile) // Isto evita nÆo concluir a impressÆo. oPrn:StartPage() oPrn:Say(lin,Col+10,chr(27)+chr(31)+chr(48)+chr(15)+'0'+usinf) lin++ oPrn:Say(lin,col+8,dtoc(date())+' - '+time()) lin++ oPrn:Say(lin,col+11,"Cupom: "+strzero(xcupom,6,0)) lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,col,"CONTROLE INTERNO, NAO E CUPOM FISCAL !!") lin++ oPrn:Say(lin,col," Comprovante para retirada de produtos") lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,Col,"Item Codigo --Descricao do Produto --") lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oitem:=1 wvalto:=0 wdesct:=0 wdemon:=0 do while !eof() wde1=len(alltrim(CUPOM->descricAO)) wde2=alltrim(substr(CUPOM->descricAO,1,26))+repli('.',26-wde1) oPrn:Say(lin,Col,cupom->produto+' '+wde2) lin++ oPrn:Say(lin,Col+03,'R$ '+transform(CUPOM->PRECO,"@e 9,999.99")+' x '+transform(CUPOM->quantidADE,"@e 999.999")+' = '+str(CUPOM->PRECO*CUPOM->QUANTIDADE,9,2)) lin++ wvalto:=wvalto+(CUPOM->PRECO*CUPOM->QUANTIDADE) wdesct:=wdesct+0 wdemon:=wvalto+wdesct skip oitem++ if lin>60 oPrn:Say(lin,Col,"----------------------------------------") lin:=1 npage=npage+1 endif enddo oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,Col+5,'Total Bruto R$ '+transform(wdemon,"@e 9,999.99")) lin++ oPrn:Say(lin,Col+5,'Descontos (-) R$ '+transform(wdesct,"@e 9,999.99")) lin++ oPrn:Say(lin,Col+5,'Total Final '+alltrim(str(oitem,4)) +" "+transform(wdemon-wdesct,"@e 9,999.99")) lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,col," EMITA A NOTA FISCAL REGULARMENTE ") lin++ oPrn:Say(lin,col," ATENCAO! NAO E COMPROVANTE FISCAL") lin++ tpvn := 0 if tpvn=6 oPrn:Say(lin,Col,'Confirmo a aquisicao dos produtos acima especi-') lin++ oPrn:Say(lin,Col,'ficados com vencimento previsto para '+dtoc(wvenc)) lin=lin+3 oPrn:Say(lin,Col,repli('_',48)) lin=lin+3 endif //oPrn:Say(lin,Col,strzero(tpvn,2)+' ('+alltrim(wnome)+'/'+alltrim(usnom)+')') oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:EndPage() // Obrigat¢rio oPrn:End(draftmode()) // Idem SysRefresh() return .t. CLASS TDosPrn DATA LastError DATA cPort, cCompress, cNormal, cFormFeed, cBuffer DATA hDC, lin, nCol, nLeftMargin, nTopMargin DATA lAnsiToOem,lCompress DATA lZeraBuffer // By Gilmer www.fivewin.com.br DATA oWnd, oPagina // Ednaldo DATA nPage AS NUMERIC // Ednaldo METHOD New(cPort) CONSTRUCTOR METHOD End() // Antigo(Old) // METHOD StartPage() VIRTUAL // NÆo Conta as P ginas // METHOD EndPage() // Novo (New) // Conta as P ginas By Ednaldo Rolim METHOD StartPage() INLINE ::ShowProc() // Ednaldo METHOD EndPage() // METHOD Command(xPar1, xPar2, xPar3, xPar4, xPar5) //velho METHOD Command(cStr1, cStr2, cStr3, cStr4, cStr5) // novo METHOD SetCoors(lin, nCol) METHOD NewLine() INLINE (::cBuffer += CRLF ,; ::lin++ ,; ::nCol := 0 ) METHOD Write(cText, lAToO) ; INLINE (iif(lAtoO == NIL, lAtoO := .T.,),; ::cBuffer += iif(lAtoO, AnsitoOem(cText), cText) ,; ::nCol += len(cText) ) METHOD Say(lin, nCol, cText, lAToO) METHOD SayCmp(lin, nCol, cText) METHOD CharSay(lin,nCol,cText) INLINE (IIf(::lCompress,; ::SayCmp(lin,nCol,cText),; ::Say(lin,nCol,cText))) METHOD ZeraBuffer() // By. Gilmer METHOD PrintFile(cFile) METHOD ShowProc() // Ednaldo ENDCLASS //----------------------------------------------------------------------------// METHOD New(cPort, lFile, lCompress) CLASS TDosPrn DEFAULT cPort := "LPT1" ,; lFile := .T. ,; lCompress := .f. cPort := Upper(cPort) ::cCompress := "15" ::cNormal := "18" ::cFormFeed := "12" ::cBuffer := "" ::nLeftMargin := 0 ::nTopMargin := 0 ::lin := 0 ::nCol := 0 ::lAnsiToOem := .T. ::cPort := cPort + iif(!"." $ cPort, ".PRN", "") ::hDC := fCreate(::cPort) ::LastError := 0 // By. Gilmer // .F. Pula P gina, .T. NÆo Pula a P gina (Cupom Fiscal) ::lZeraBuffer:=.T. IF ::hDC < 0 ::LastError := fError() ENDIF ::nPage := 1 // Ednaldo ::ShowProc() // Ednaldo RETURN Self //----------------------------------------------------------------------------// METHOD End() CLASS TDosPrn IF !empty(::lin+::nCol) ::EndPage() ENDIF ::LastError := 0 IF !fClose(::hDC) ::LastError := fError() ENDIF CursorArrow() if ::oWnd != Nil // Ednaldo ::oWnd:End() // Ednaldo endif // Ednaldo RETURN NIL //----------------------------------------------------------------------------// METHOD EndPage() CLASS TDosPrn LOCAL nFor, nLen, nSec LOCAL lError If !::lZeraBuffer // By Gilmer ::Command(::cFormFeed) End ::LastError := 0 IF fWrite(::hDC, ::cBuffer) < len(::cBuffer) ::LastError := fError() ENDIF ::cBuffer := "" ::lin := 0 ::nCol := 0 RETURN NIL //----------------------------------------------------------------------------// //METHOD Command(xPar1, xPar2, xPar3, xPar4, xPar5) CLASS TDosPrn // Velho METHOD Command(cStr1, cStr2, cStr3, cStr4, cStr5) CLASS TDosPrn // Novo LOCAL cCommand, cToken, cString LOCAL nToken //cString := cValToChar(xPar1) // Velho cString := cStr1 // Novo /* // Velho IF xPar2 != NIL cString += ","+cValToChar(xPar2) ENDIF */ IF cStr2 != NIL cString += ","+cStr2 ENDIF /* // Velho IF xPar3 != NIL cString += ","+cValToChar(xPar3) ENDIF */ IF cStr3 != NIL cString += ","+cStr3 ENDIF /* // Velho IF xPar4 != NIL cString += ","+cValToChar(xPar4) ENDIF */ IF cStr4 != NIL cString += ","+cStr4 ENDIF /* // Velho IF xPar5 != NIL cString += ","+cValToChar(xPar5) ENDIF */ IF cStr5 != NIL cString += ","+cStr5 ENDIF cCommand := "" nToken := 1 DO WHILE !Empty(cToken := StrToken(cString, nToken++, ",")) cCommand += Chr(Val(cToken)) ENDDO ::cBuffer += cCommand RETURN NIL //----------------------------------------------------------------------------// METHOD SetCoors(lin, nCol) CLASS TDosPrn lin += ::nTopMargin nCol += ::nLeftMargin IF ::lin > lin ::EndPage() ::nPage++ // Ednaldo ::StartPage() ENDIF /* // do Site IF ::lin > lin ::EndPage() ::StartPage() ENDIF */ IF lin == ::lin .AND. nCol < ::nCol ::EndPage() ::nPage++ // Ednaldo ::StartPage() ENDIF /* // do Site IF lin == ::lin .AND. nCol < ::nCol ::EndPage() ::StartPage() ENDIF */ DO WHILE ::lin < lin ::NewLine() ENDDO IF nCol > ::nCol ::Write(Space(nCol-::nCol)) ENDIF // By. Gilmer If Len(::cBuffer)>=7928 ::ZeraBuffer() End RETURN NIL //----------------------------------------------------------------------------// METHOD Say(lin, nCol, cText, lAToO) CLASS TDosPrn DEFAULT lAToO := ::lAnsiToOem IF VALTYPE( cText ) = "D" cText := DTOC( cText ) ENDIF IF VALTYPE( cText ) = "N" cText := STR( cText ) ENDIF ::SetCoors(lin, nCol) ::Write(cText, lAToO) RETURN NIL //----------------------------------------------------------------------------// METHOD SayCmp(lin, nCol, cText, lAToO) CLASS TDosPrn DEFAULT lAToO := ::lAnsiToOem ::Command(::cCompress) ::SetCoors(lin, nCol) ::cBuffer += iif(lAToO, AnsitoOem(cText), cText) ::nCol += Int(len(cText)) * by Digao ::nCol += Int(len(cText)/1.7+.5) ::Command(::cNormal) RETURN NIL //----------------------------------------------------------------------------// METHOD ZeraBuffer() CLASS TDosPrn ::LastError := 0 If ::lZeraBuffer IF fWrite(::hDC, ::cBuffer) < len(::cBuffer) ::LastError := fError() ENDIF ::cBuffer := "" End RETURN NIL //----------------------------------------------------------------------------// FUNCTION WorkSheet(cPort) LOCAL oPrn LOCAL cLine LOCAL nFor cLine := "" FOR nFor := 0 TO 7 cLine += Str(nFor,1)+Replicate(".",9) NEXT cLine := Substr(cLine,3) oPrn := TDosPrn():New(cPort) oPrn:StartPage() FOR nFor := 0 TO 65 oPrn:Say(nFor,0,StrZero(nFor,2)+cLine) NEXT oPrn:EndPage() oPrn:End() RETURN NIL //----------------------------------------------------------------------------// METHOD PrintFile(cFile) CLASS TDosPrn LOCAL hFile LOCAL nRead LOCAL cBuffer hFile := FOpen(cFile, FO_READ) IF hFile < 0 RETURN .F. ENDIF cBuffer := Space(PF_BUFLEN) DO nRead := fRead(hFile, @cBuffer, PF_BUFLEN) IF fWrite(::hDC, Left(cBuffer, nRead)) < nRead ::LastError := fError() fClose(hFile) RETURN .F. ENDIF UNTIL nRead == PF_BUFLEN fClose(hFile) RETURN .T. //----------------------------------------------------------------------------// // Visualiza Processo de impressao // Ednaldo //----------------------------------------------------------------------------// METHOD ShowProc() CLASS TDosPrn IF ::oWnd = Nil DEFINE DIALOG ::oWnd TITLE "Imprimindo ..." ; FROM 230, 217 TO 360, 575 PIXEL ; COLORS CLBLACK, nRGB(193,205,205) @ 10, 08 TO 40, 172 OF ::oWnd PIXEL @ 1.4, 2 ICON NAME "PRINT.ICO" OF ::oWnd @ 25, 35 SAY "Imprimindo Página :" ; PIXEL OF ::oWnd SIZE 70, 12 RIGHT @ 25, 107 SAY ::oPagina VAR ::nPage ; PIXEL OF ::oWnd UPDATE SIZE 15, 12 RIGHT @ 47, 60 BUTTON "Aguarde..." SIZE 60, 12 ; PIXEL OF ::oWnd ACTION .t. ::oWnd:bPainted := {|| iif(::nPage>0, ::oPagina:Refresh(), )} ACTIVATE DIALOG ::oWnd CENTER NOWAIT CursorWait() SysRefresh() ELSE ::oWnd:BeginPaint() ::oWnd:Paint() ::oWnd:EndPaint() ENDIF RETURN NIL Quote Link to comment Share on other sites More sharing options...
jose hilton Posted November 4, 2005 Author Report Share Posted November 4, 2005 Boa tarde pessoal a) Se alguem poder mim responder porque que eu alguns micros esse comando nao funciona e em outros sim. Como faco para condenca a impressao em HP Grato Hilton Jose Hilton FWH 2.6 function LISTAR(olbx) ******************************* lin:=1 Col:=0 npage:=1 latoo := .t. DBSELECTAREA("CUPOM") GO TOP if ! oPrn:isprinter() msginfo("Verifique a Impressora") endif usinf:=alltrim("PLANETA BELEZA") cFile:="REPORT.PRN" //  melhor imprimir primeiro para arquivo. oPrn:=TDosPrn():New(cFile) // Isto evita nÆo concluir a impressÆo. oPrn:StartPage() oPrn:Say(lin,Col+10,chr(27)+chr(31)+chr(48)+chr(15)+'0'+usinf) lin++ oPrn:Say(lin,col+8,dtoc(date())+' - '+time()) lin++ oPrn:Say(lin,col+11,"Cupom: "+strzero(xcupom,6,0)) lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,col,"CONTROLE INTERNO, NAO E CUPOM FISCAL !!") lin++ oPrn:Say(lin,col," Comprovante para retirada de produtos") lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,Col,"Item Codigo --Descricao do Produto --") lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oitem:=1 wvalto:=0 wdesct:=0 wdemon:=0 do while !eof() wde1=len(alltrim(CUPOM->descricAO)) wde2=alltrim(substr(CUPOM->descricAO,1,26))+repli('.',26-wde1) oPrn:Say(lin,Col,cupom->produto+' '+wde2) lin++ oPrn:Say(lin,Col+03,'R$ '+transform(CUPOM->PRECO,"@e 9,999.99")+' x '+transform(CUPOM->quantidADE,"@e 999.999")+' = '+str(CUPOM->PRECO*CUPOM->QUANTIDADE,9,2)) lin++ wvalto:=wvalto+(CUPOM->PRECO*CUPOM->QUANTIDADE) wdesct:=wdesct+0 wdemon:=wvalto+wdesct skip oitem++ if lin>60 oPrn:Say(lin,Col,"----------------------------------------") lin:=1 npage=npage+1 endif enddo oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,Col+5,'Total Bruto R$ '+transform(wdemon,"@e 9,999.99")) lin++ oPrn:Say(lin,Col+5,'Descontos (-) R$ '+transform(wdesct,"@e 9,999.99")) lin++ oPrn:Say(lin,Col+5,'Total Final '+alltrim(str(oitem,4)) +" "+transform(wdemon-wdesct,"@e 9,999.99")) lin++ oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:Say(lin,col," EMITA A NOTA FISCAL REGULARMENTE ") lin++ oPrn:Say(lin,col," ATENCAO! NAO E COMPROVANTE FISCAL") lin++ tpvn := 0 if tpvn=6 oPrn:Say(lin,Col,'Confirmo a aquisicao dos produtos acima especi-') lin++ oPrn:Say(lin,Col,'ficados com vencimento previsto para '+dtoc(wvenc)) lin=lin+3 oPrn:Say(lin,Col,repli('_',48)) lin=lin+3 endif //oPrn:Say(lin,Col,strzero(tpvn,2)+' ('+alltrim(wnome)+'/'+alltrim(usnom)+')') oPrn:Say(lin,Col,"----------------------------------------") lin++ oPrn:EndPage() // Obrigat¢rio oPrn:End(draftmode()) // Idem SysRefresh() return .t. CLASS TDosPrn DATA LastError DATA cPort, cCompress, cNormal, cFormFeed, cBuffer DATA hDC, lin, nCol, nLeftMargin, nTopMargin DATA lAnsiToOem,lCompress DATA lZeraBuffer // By Gilmer www.fivewin.com.br DATA oWnd, oPagina // Ednaldo DATA nPage AS NUMERIC // Ednaldo METHOD New(cPort) CONSTRUCTOR METHOD End() // Antigo(Old) // METHOD StartPage() VIRTUAL // NÆo Conta as P ginas // METHOD EndPage() // Novo (New) // Conta as P ginas By Ednaldo Rolim METHOD StartPage() INLINE ::ShowProc() // Ednaldo METHOD EndPage() // METHOD Command(xPar1, xPar2, xPar3, xPar4, xPar5) //velho METHOD Command(cStr1, cStr2, cStr3, cStr4, cStr5) // novo METHOD SetCoors(lin, nCol) METHOD NewLine() INLINE (::cBuffer += CRLF ,; ::lin++ ,; ::nCol := 0 ) METHOD Write(cText, lAToO) ; INLINE (iif(lAtoO == NIL, lAtoO := .T.,),; ::cBuffer += iif(lAtoO, AnsitoOem(cText), cText) ,; ::nCol += len(cText) ) METHOD Say(lin, nCol, cText, lAToO) METHOD SayCmp(lin, nCol, cText) METHOD CharSay(lin,nCol,cText) INLINE (IIf(::lCompress,; ::SayCmp(lin,nCol,cText),; ::Say(lin,nCol,cText))) METHOD ZeraBuffer() // By. Gilmer METHOD PrintFile(cFile) METHOD ShowProc() // Ednaldo ENDCLASS //----------------------------------------------------------------------------// METHOD New(cPort, lFile, lCompress) CLASS TDosPrn DEFAULT cPort := "LPT1" ,; lFile := .T. ,; lCompress := .f. cPort := Upper(cPort) ::cCompress := "15" ::cNormal := "18" ::cFormFeed := "12" ::cBuffer := "" ::nLeftMargin := 0 ::nTopMargin := 0 ::lin := 0 ::nCol := 0 ::lAnsiToOem := .T. ::cPort := cPort + iif(!"." $ cPort, ".PRN", "") ::hDC := fCreate(::cPort) ::LastError := 0 // By. Gilmer // .F. Pula P gina, .T. NÆo Pula a P gina (Cupom Fiscal) ::lZeraBuffer:=.T. IF ::hDC < 0 ::LastError := fError() ENDIF ::nPage := 1 // Ednaldo ::ShowProc() // Ednaldo RETURN Self //----------------------------------------------------------------------------// METHOD End() CLASS TDosPrn IF !empty(::lin+::nCol) ::EndPage() ENDIF ::LastError := 0 IF !fClose(::hDC) ::LastError := fError() ENDIF CursorArrow() if ::oWnd != Nil // Ednaldo ::oWnd:End() // Ednaldo endif // Ednaldo RETURN NIL //----------------------------------------------------------------------------// METHOD EndPage() CLASS TDosPrn LOCAL nFor, nLen, nSec LOCAL lError If !::lZeraBuffer // By Gilmer ::Command(::cFormFeed) End ::LastError := 0 IF fWrite(::hDC, ::cBuffer) < len(::cBuffer) ::LastError := fError() ENDIF ::cBuffer := "" ::lin := 0 ::nCol := 0 RETURN NIL //----------------------------------------------------------------------------// //METHOD Command(xPar1, xPar2, xPar3, xPar4, xPar5) CLASS TDosPrn // Velho METHOD Command(cStr1, cStr2, cStr3, cStr4, cStr5) CLASS TDosPrn // Novo LOCAL cCommand, cToken, cString LOCAL nToken //cString := cValToChar(xPar1) // Velho cString := cStr1 // Novo /* // Velho IF xPar2 != NIL cString += ","+cValToChar(xPar2) ENDIF */ IF cStr2 != NIL cString += ","+cStr2 ENDIF /* // Velho IF xPar3 != NIL cString += ","+cValToChar(xPar3) ENDIF */ IF cStr3 != NIL cString += ","+cStr3 ENDIF /* // Velho IF xPar4 != NIL cString += ","+cValToChar(xPar4) ENDIF */ IF cStr4 != NIL cString += ","+cStr4 ENDIF /* // Velho IF xPar5 != NIL cString += ","+cValToChar(xPar5) ENDIF */ IF cStr5 != NIL cString += ","+cStr5 ENDIF cCommand := "" nToken := 1 DO WHILE !Empty(cToken := StrToken(cString, nToken++, ",")) cCommand += Chr(Val(cToken)) ENDDO ::cBuffer += cCommand RETURN NIL //----------------------------------------------------------------------------// METHOD SetCoors(lin, nCol) CLASS TDosPrn lin += ::nTopMargin nCol += ::nLeftMargin IF ::lin > lin ::EndPage() ::nPage++ // Ednaldo ::StartPage() ENDIF /* // do Site IF ::lin > lin ::EndPage() ::StartPage() ENDIF */ IF lin == ::lin .AND. nCol < ::nCol ::EndPage() ::nPage++ // Ednaldo ::StartPage() ENDIF /* // do Site IF lin == ::lin .AND. nCol < ::nCol ::EndPage() ::StartPage() ENDIF */ DO WHILE ::lin < lin ::NewLine() ENDDO IF nCol > ::nCol ::Write(Space(nCol-::nCol)) ENDIF // By. Gilmer If Len(::cBuffer)>=7928 ::ZeraBuffer() End RETURN NIL //----------------------------------------------------------------------------// METHOD Say(lin, nCol, cText, lAToO) CLASS TDosPrn DEFAULT lAToO := ::lAnsiToOem IF VALTYPE( cText ) = "D" cText := DTOC( cText ) ENDIF IF VALTYPE( cText ) = "N" cText := STR( cText ) ENDIF ::SetCoors(lin, nCol) ::Write(cText, lAToO) RETURN NIL //----------------------------------------------------------------------------// METHOD SayCmp(lin, nCol, cText, lAToO) CLASS TDosPrn DEFAULT lAToO := ::lAnsiToOem ::Command(::cCompress) ::SetCoors(lin, nCol) ::cBuffer += iif(lAToO, AnsitoOem(cText), cText) ::nCol += Int(len(cText)) * by Digao ::nCol += Int(len(cText)/1.7+.5) ::Command(::cNormal) RETURN NIL //----------------------------------------------------------------------------// METHOD ZeraBuffer() CLASS TDosPrn ::LastError := 0 If ::lZeraBuffer IF fWrite(::hDC, ::cBuffer) < len(::cBuffer) ::LastError := fError() ENDIF ::cBuffer := "" End RETURN NIL //----------------------------------------------------------------------------// FUNCTION WorkSheet(cPort) LOCAL oPrn LOCAL cLine LOCAL nFor cLine := "" FOR nFor := 0 TO 7 cLine += Str(nFor,1)+Replicate(".",9) NEXT cLine := Substr(cLine,3) oPrn := TDosPrn():New(cPort) oPrn:StartPage() FOR nFor := 0 TO 65 oPrn:Say(nFor,0,StrZero(nFor,2)+cLine) NEXT oPrn:EndPage() oPrn:End() RETURN NIL //----------------------------------------------------------------------------// METHOD PrintFile(cFile) CLASS TDosPrn LOCAL hFile LOCAL nRead LOCAL cBuffer hFile := FOpen(cFile, FO_READ) IF hFile < 0 RETURN .F. ENDIF cBuffer := Space(PF_BUFLEN) DO nRead := fRead(hFile, @cBuffer, PF_BUFLEN) IF fWrite(::hDC, Left(cBuffer, nRead)) < nRead ::LastError := fError() fClose(hFile) RETURN .F. ENDIF UNTIL nRead == PF_BUFLEN fClose(hFile) RETURN .T. //----------------------------------------------------------------------------// // Visualiza Processo de impressao // Ednaldo //----------------------------------------------------------------------------// METHOD ShowProc() CLASS TDosPrn IF ::oWnd = Nil DEFINE DIALOG ::oWnd TITLE "Imprimindo ..." ; FROM 230, 217 TO 360, 575 PIXEL ; COLORS CLBLACK, nRGB(193,205,205) @ 10, 08 TO 40, 172 OF ::oWnd PIXEL @ 1.4, 2 ICON NAME "PRINT.ICO" OF ::oWnd @ 25, 35 SAY "Imprimindo Página :" ; PIXEL OF ::oWnd SIZE 70, 12 RIGHT @ 25, 107 SAY ::oPagina VAR ::nPage ; PIXEL OF ::oWnd UPDATE SIZE 15, 12 RIGHT @ 47, 60 BUTTON "Aguarde..." SIZE 60, 12 ; PIXEL OF ::oWnd ACTION .t. ::oWnd:bPainted := {|| iif(::nPage>0, ::oPagina:Refresh(), )} ACTIVATE DIALOG ::oWnd CENTER NOWAIT CursorWait() SysRefresh() ELSE ::oWnd:BeginPaint() ::oWnd:Paint() ::oWnd:EndPaint() ENDIF RETURN NIL Quote Link to comment Share on other sites More sharing options...
personal Posted November 4, 2005 Report Share Posted November 4, 2005 Legal seu Estadão. Como diria o Kapi. Uma coisa é uma coisa e outra coisa é outra coisa. Tandeu. Comandos da Epson = Manual Epson. Comandos HP = Manual HP PCL Quote Link to comment Share on other sites More sharing options...
pauloaraujo Posted November 4, 2005 Report Share Posted November 4, 2005 José Hilton, tudo bem?? São esses comandos que uso para condensar na HP: WI_ESPACEJ_FIXO = CHR(27)+"(s0P" WI_FONTE = CHR(27)+"(10U" WI_PICH = CHR(27)+"(s"+STR(16.67)+"H" WI_ALTUR_CARACT = CHR(27)+"(s"+STR(8.5)+"V" WI_MOVIM_HORIZ = CHR(27)+"&k"+STR(7)+"H" WI_LIMPAMARG = CHR(27)+"9" oPrn:Say(lin,col,WI_ESPACEJ_FIXO + WI_FONTE + WI_PICH + ; WI_ALTUR_CARACT + WI_MOVIM_HORIZ + WI_LIMPAMARG) E esses para voltar ao normal: WI_ESPACEJ_FIXO = CHR(27)+"(s0P" WI_FONTE = CHR(27)+"(10U" WI_PICH = CHR(27)+"(s"+STR(10)+"H" WI_ALTUR_CARACT = CHR(27)+"(s"+STR(10)+"V" WI_MOVIM_HORIZ = CHR(27)+"&k"+STR(11.5)+"H" WI_LIMPAMARG = CHR(27)+"9" oPrn:Say(lin,col,WI_ESPACEJ_FIXO + WI_FONTE + WI_PICH + ; WI_ALTUR_CARACT + WI_MOVIM_HORIZ + WI_LIMPAMARG) Um abraço Paulo/CONTATO SISTEMAS Clipper53b / FW26 / Blinker70 Ajudar é um prazer, agradecer é uma obrigação PRESTIGIEM O III ENCONTRO DE USUÃRIOS DE FIVEWIN - 2005 Inscreva-se: http://www.installsis.com.br/encontro Editado por - pauloaraujo on 04/11/2005 17:07:06 Quote Link to comment Share on other sites More sharing options...
Luiz Arruda (ICO) Posted November 4, 2005 Report Share Posted November 4, 2005 Veja; http://www.fivewin.com.br/forum/topic.asp?TOPIC_ID=5007 Com isto vc. faz exatamente como fazia em CLIPPER puro. Visite; http://www.vagucs.com.br Abraços LUIZ ARRUDA - Corumba-MS FW 2.4 - CLP 5.3 - WS iko67@ibest.com.br Não Percam - 3º ENCONTRO DE FIVEWINERS - NOVEMBRO DE 2005 Editado por - ico on 04/11/2005 17:30:28 Editado por - ico on 04/11/2005 17:32:00 Quote Link to comment Share on other sites More sharing options...
pauloaraujo Posted November 4, 2005 Report Share Posted November 4, 2005 Ico, Onde estão os comandos para a HP nesse tópico que você apontou???? José Hilton, O personal lembrou bem. Você vai ter que fazer uma pergunta antes de imprimir, se o padrão será Epson ou HP. If wPadrao="Epson" CHR(15) else && aqueles comandos que mostrei endif Aliás, para falar a verdade, não uso esses comandos da HP em Fivewin. Somente Clipper. Em FW eu uso: . Matricial: TDOSPRN - CHR(15) . Gráfico : TPRINTER - não precisa de comandos para impressora. Paulo/CONTATO SISTEMAS Clipper53b / FW26 / Blinker70 Ajudar é um prazer, agradecer é uma obrigação PRESTIGIEM O III ENCONTRO DE USUÃRIOS DE FIVEWIN - 2005 Inscreva-se: http://www.installsis.com.br/encontro Editado por - pauloaraujo on 04/11/2005 17:54:55 Quote Link to comment Share on other sites More sharing options...
jose hilton Posted November 7, 2005 Author Report Share Posted November 7, 2005 Valeu PauloAraujo Resolvir meu Problema de condensar a HP e sobre esse erro constate que da em alguns micro de nao achar a porta vc tem alguma sogestao Grato Hilton FWH 2.6 Quote Link to comment Share on other sites More sharing options...
syspel Posted November 7, 2005 Report Share Posted November 7, 2005 voce deve criar um arquivo c:\temp e deves enquanto fazer limpresa no temporario files ok ailton syspel Quote Link to comment Share on other sites More sharing options...
pauloaraujo Posted November 7, 2005 Report Share Posted November 7, 2005 citação:Valeu PauloAraujo Resolvir meu Problema de condensar a HP e sobre esse erro constate que da em alguns micro de nao achar a porta vc tem alguma sogestao Grato Hilton FWH 2.6 id=quote>id=quote>Hilton, Como já disse, esses comandos que te passei só uso em Clipper, embora funcionem também em FW. A sugestão que te dou é só usar a TDOSPRN para impressoras matriciais. Para padrão gráfico, seja qual for a impressora, use a TPRINTER. Dá para usar as 2 classes sem crise. Vê se te ajuda esse exemplo: Eu fiz o seguinte: antes da impressão eu pergunto para o usuário qual o padrão que ele vai usar e armazeno a informação numa variável de memória chamada WTPIMPRES "M" && matricial "G" && grafico "A" && arquivo if WTPIMPRES="G" PRINTERSETUP() MsgRun( "MONTANDO O RELATORIO PARA MOSTRAR EM TELA - AGUARDE !! !! ...... ","", ; { | oTmp | IMPSCC02(oTmp) } ) else IMPSCC02(oTmp) endif Na impressão eu uso o seguinte código: nNumLinGr:=61 nNumCol_c:=132 nNumCol_n:=80 WLIN:=0 WCOL:=1 PAG:=1 PRIV Lim_Linhas, oFont , oPrn IF WTPIMPRES#"G" #xcommand @ , PSAY => oPrin:Say(,,) Lim_Linhas :=61 // modo texto oPrin:= TDosPrn():new(WDIRPORTA) oPrin:StartPage() // da Start(inicializa) na página. oPrin:lZeraBuffer:=.T. // Pular Página=.F. Nao Pular=.T. REDUZ(0) ELSE PRINT oPrn NAME "RELSCC02" PREVIEW // modo grafico Lim_Linhas:=VirCfgFont(oPrn,WFONTEREL,@oFont,"C") PAGE ENDIF e assim por diante wvar1_impr = STR(TRANSCOD,3,0)+" "+; DTOC(DATACAD)+" "+; TRANSDESCR+" "+; ENDERECO+" "+; SUBS(CONTATO,1,27)+" "+; TRANS(CGC,"99.999.999/9999-99") IF WTPIMPRES#"G" @ WLIN+=2,WCOL PSAY wvar1_impr ELSE oPrn:CharSay(WLIN+=2, WCOL, wvar1_impr) ENDIF no fim: IF WTPIMPRES#"G" oPrin:lZeraBuffer:=.F. // Pular Página=.F. oPrin:EndPage() // Obrigatorio oPrin:End() // Idem ImpSpool( "C:\PLENOTMP\RELAT.TXT",, .T. ) ELSE ENDPAGE ENDPRINT ENDIF Paulo/CONTATO SISTEMAS Clipper53b / FW26 / Blinker70 Ajudar é um prazer, agradecer é uma obrigação PRESTIGIEM O III ENCONTRO DE USUÃRIOS DE FIVEWIN - 2005 Inscreva-se: http://www.installsis.com.br/encontro Quote Link to comment Share on other sites More sharing options...
Luiz Arruda (ICO) Posted November 8, 2005 Report Share Posted November 8, 2005 citação:Ico, Onde estão os comandos para a HP nesse tópico que você apontou???? José Hilton, O personal lembrou bem. Você vai ter que fazer uma pergunta antes de imprimir, se o padrão será Epson ou HP. If wPadrao="Epson" CHR(15) else && aqueles comandos que mostrei endif Aliás, para falar a verdade, não uso esses comandos da HP em Fivewin. Somente Clipper. Em FW eu uso: . Matricial: TDOSPRN - CHR(15) . Gráfico : TPRINTER - não precisa de comandos para impressora. Paulo/CONTATO SISTEMAS Clipper53b / FW26 / Blinker70 Ajudar é um prazer, agradecer é uma obrigação PRESTIGIEM O III ENCONTRO DE USUÃRIOS DE FIVEWIN - 2005 Inscreva-se: http://www.installsis.com.br/encontro Editado por - pauloaraujo on 04/11/2005 17:54:55 id=quote>id=quote>OLA. PAULO TO MEIO ATRAZADO P/ RESPONDER MAIS VAI LÃ. O QUE TENTEI MOSTRAR É QUE USANDO A PRWIN DO VAGNER NUNES, A GENTE FAZ TUDO EXATAMENTE COMO NO CLIPPER, CONCLUINDO; NAO PRECISANDO NEM USAR A TDOSPRN. veja o que consegui sem usar a tdosPrn e imprimindo em FW e em impressora Epson LX-300+ neste tópico. http://www.fivewin.com.br/forum/topic.asp?TOPIC_ID=5007 PS: ISSO PARA IMPRESSORA MATRICIAL LUIZ ARRUDA - Corumba-MS FW 2.4 - CLP 5.3 - WS iko67@ibest.com.br Não Percam - 3º ENCONTRO DE FIVEWINERS - NOVEMBRO DE 2005 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.