erro win32prn() no pdfcreator

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

lapinhazzz
Usuário Nível 3
Usuário Nível 3
Mensagens: 130
Registrado em: 20 Abr 2009 10:52
Localização: LAGOA

erro win32prn() no pdfcreator

Mensagem por lapinhazzz »

Boa Noite,

Tenho aquela rotina que postaram aqui no forum que se chama impusb.prg que imprime em win32prn()
Só que a segunda página aparece-me um erro:

ERROR: syntaxerror
OFFENDING COMMAND: --nostringval--
STACK:

A rotina para iniciantes que eu tenho e modificada é esta

Código: Selecionar todos

*--------------------------------------------------------------------------------------
#define FORM_A4 9
#define RGB( nR,nG,nB ) ( nR + ( nG * 256 ) + ( nB * 256 * 256 ) )
#define PS_SOLID 0
#define BLACK RGB( 0x0 ,0x0 ,0x0 )
#define BLUE RGB( 0x0 ,0x0 ,0x85 )
#define GREEN RGB( 0x0 ,0x85,0x0 )
#define CYAN RGB( 0x0 ,0x85,0x85 )
#define RED RGB( 0x85,0x0 ,0x0 )
#define MAGENTA RGB( 0x85,0x0 ,0x85 )
#define BROWN RGB( 0x85,0x85,0x0 )
#define WHITE RGB( 0xC6,0xC6,0xC6 )
*
*--------------------------------------------------------------------------------------
FUNCTION Main()
   LOCAL nPrn:=1
   LOCAL aPrn:= GetPrinters()
   CLS
   sele 3
   use produtos
   skip
   IF EMPTY(aPrn)
      Alert("No printers installed - Cannot continue")
      QUIT
   ENDIF
   DO WHILE !EMPTY(nPrn)
      CLS
      @ 0,0 SAY 'Programa Fotoc¢pias - Escolha uma impressora. ESC' +;
         ' para sair.'
      @ 1,0 TO maxRow(),maxCol()
      nPrn:= ACHOICE(2,1,maxRow()-1,maxCol()-1,aPrn,.T.,,nPrn)
      IF !EMPTY(nPrn)
         PrnTest(aPrn[nPrn])
      ENDIF
   ENDDO
   *
   @ 22,00 say ""
RETURN(NIL)
*
*--------------------------------------------------------------------------------------
STATIC FUNCTION PrnTest(cPrinter)
   LOCAL oPrinter:= WIN32PRN():New(cPrinter), aFonts, x, nColFixed, nColTTF, ;
      nColCharSet, aForms
   oPrinter:Landscape:= .F.
   oPrinter:FormType := FORM_A4
   oPrinter:Copies := 1
   *
   c_string := "Foto-" + LTRIM(STR(YEAR(DATE()))) + "-" + STRZERO(MONTH(DATE()),2) +;
      "-" + LTRIM(STR(DAY(DATE()))) + "=" + TIME()
   *
   IF !oPrinter:Create()
      Alert("Cannot Create Printer")
   ELSE
      IF !oPrinter:startDoc( c_string )
         Alert("StartDoc() failed")
      ELSE
         nFont := 12
         oPrinter:SetFont('Courier New',12,{1,nFont}, 0, .F., .F.)

         FOR N = 1 TO 2
            oPrinter:NewLine()
         NEXT N
         *
         *-----------------------------------------------------------------------------

         *================================== Busca de informa‡äes =====================

         oPrinter:TextOut("Impressora: " + oPrinter:PrinterName + ' ' +;
            'MaxRow() = '+ltrim(STR(oPrinter:MaxRow(),4)) +;
            ' MaxCol() = '+ltrim(STR(oPrinter:MaxCol(),4)) , .t.)

         oPrinter:NewLine()
         oPrinter:SetFont('Courier New',12,{1,nFont}, 0, .F., .F.)

         oPrinter:Textout(STR(oprinter:LineHeight() ) + " -altura da linha",.t.)
         oPrinter:Textout(STR(oprinter:CharWidth() ) + " -largura da coluna",.T.)
         oPrinter:TextOut(STR(oPrinter:Prow() ) + " -N£mero da linha",.T.)
         oPrinter:TextOut(STR(oPrinter:GetCharWidth() ) + " -GetCharWidth",.T.)
         oPrinter:TextOut(STR(oPrinter:GetCharHeight() ) + " -GetCharHeigth",.T.)
         oPrinter:Textout(STR(oprinter:Prow() ) + " -Posi‡Æo atual da " +;
            "linha",.T.)
/*
Onde:
oPrinter:TextOut("Texto a ser impresso",.T.)
1-Texto;
2-Opcional: Avan‡a linha automaticamente (.T.) ou nÆo (.F.),
sendo (.F.) o seu valor Default, quando suprimido.
*/
         *======================= Aqui come‡a a impressÆo da 1¦ p gina ================



         oPrinter:TextAtFont(oPrinter:mm_to_posx(105),oPrinter:mm_to_posy(75), +;
            "Listagem de Fotocopias - Descricao e Precos","Courier New", +;
            16,,700,,.T.,,,,,2)


         oPrinter:NewLine()
         FOR nLinha = 1 TO 29
            oPrinter:SetPrc(oPrinter:Prow()+01, 20 )
            oPrinter:Textout(codigoprod+'   '+prod+'    '+'  '+str(precov)+;
               '  '+copias+'  '+cor,.f.)
            skip
         NEXT nLinha
      endi
   endi
return
Obrigado

lapinhazzz
:{
Avatar do usuário
gvc
Colaborador
Colaborador
Mensagens: 1270
Registrado em: 23 Ago 2005 10:57

Re: erro win32prn() no pdfcreator

Mensagem por gvc »

Esse erro é durante a compilação ou execução?
Vc conseguiu determinar se é em alguma linha do sistema? (runtime error)
"TRS-80/Sincler/Apple/PC - Clipper Winter 85, tlink 1.0 [pc 10 MHz - 640K] {NEZ 8000 2Kb RAM}"
{POG - Programação Orientada a Gambiarra}
Hasse
Usuário Nível 4
Usuário Nível 4
Mensagens: 820
Registrado em: 19 Out 2004 10:30
Localização: Jaraguá do Sul - SC

Re: erro win32prn() no pdfcreator

Mensagem por Hasse »

O erro está no final do código. Faltando:
oPrinter:EndDoc()
oPrinter:Destroy()


Depopis de devidamente modificado, testei o código abaixo e está funcionando.

Código: Selecionar todos

*--------------------------------------------------------------------------------------
#define FORM_A4 9
#define RGB( nR,nG,nB ) ( nR + ( nG * 256 ) + ( nB * 256 * 256 ) )
#define PS_SOLID 0
#define BLACK RGB( 0x0 ,0x0 ,0x0 )
#define BLUE RGB( 0x0 ,0x0 ,0x85 )
#define GREEN RGB( 0x0 ,0x85,0x0 )
#define CYAN RGB( 0x0 ,0x85,0x85 )
#define RED RGB( 0x85,0x0 ,0x0 )
#define MAGENTA RGB( 0x85,0x0 ,0x85 )
#define BROWN RGB( 0x85,0x85,0x0 )
#define WHITE RGB( 0xC6,0xC6,0xC6 )
*
*--------------------------------------------------------------------------------------
FUNCTION Main()
   LOCAL nPrn:=1
   LOCAL aPrn:= GetPrinters()
   CLS
   sele 3
   use produtos
   skip
   IF EMPTY(aPrn)
      Alert("No printers installed - Cannot continue")
      QUIT
   ENDIF
   DO WHILE !EMPTY(nPrn)
      CLS
      @ 0,0 SAY 'Programa Fotoc¢pias - Escolha uma impressora. ESC' +;
         ' para sair.'
      @ 1,0 TO maxRow(),maxCol()
      nPrn:= ACHOICE(2,1,maxRow()-1,maxCol()-1,aPrn,.T.,,nPrn)
      IF !EMPTY(nPrn)
         PrnTest(aPrn[nPrn])
      ENDIF
   ENDDO
   *
   @ 22,00 say ""
RETURN(NIL)
*
*--------------------------------------------------------------------------------------
STATIC FUNCTION PrnTest(cPrinter)
   LOCAL oPrinter:= WIN32PRN():New(cPrinter), aFonts, x, nColFixed, nColTTF, nColCharSet, aForms
   oPrinter:Landscape := .F.
   oPrinter:FormType  := FORM_A4
   oPrinter:Copies    := 1
   *
   c_string := "Foto-" + LTRIM(STR(YEAR(DATE()))) + "-" + STRZERO(MONTH(DATE()),2) +;
      "-" + LTRIM(STR(DAY(DATE()))) + "=" + TIME()
   *
   IF !oPrinter:Create()
      Alert("Cannot Create Printer")
   ELSE
      IF !oPrinter:startDoc( c_string )
         Alert("StartDoc() failed")
      ELSE
         nFont := 12
         oPrinter:SetFont('Courier New',12,{1,nFont}, 0, .F., .F.)

         FOR N = 1 TO 2
            oPrinter:NewLine()
         NEXT N
         *
         *-----------------------------------------------------------------------------

         *================================== Busca de informações =====================

         oPrinter:TextOut("Impressora: " + oPrinter:PrinterName + ' ' +;
            'MaxRow() = '+ltrim(STR(oPrinter:MaxRow(),4)) +;
            ' MaxCol() = '+ltrim(STR(oPrinter:MaxCol(),4)) , .t.)

         oPrinter:NewLine()
         oPrinter:SetFont('Courier New',12,{1,nFont}, 0, .F., .F.)

         oPrinter:Textout(STR(oprinter:LineHeight() ) + " -altura da linha",.t.)
         oPrinter:Textout(STR(oprinter:CharWidth() ) + " -largura da coluna",.T.)
         oPrinter:TextOut(STR(oPrinter:Prow() ) + " -N£mero da linha",.T.)
         oPrinter:TextOut(STR(oPrinter:GetCharWidth() ) + " -GetCharWidth",.T.)
         oPrinter:TextOut(STR(oPrinter:GetCharHeight() ) + " -GetCharHeigth",.T.)
         oPrinter:Textout(STR(oprinter:Prow() ) + " -Posi‡Æo atual da " +;
            "linha",.T.)
/*
Onde:
oPrinter:TextOut("Texto a ser impresso",.T.)
1-Texto;
2-Opcional: Avan‡a linha automaticamente (.T.) ou nÆo (.F.),
sendo (.F.) o seu valor Default, quando suprimido.
*/
         *======================= Aqui come‡a a impressÆo da 1¦ p gina ================



         oPrinter:TextAtFont(oPrinter:mm_to_posx(105),oPrinter:mm_to_posy(75), +;
            "Listagem de Fotocopias - Descricao e Precos","Courier New", +;
            16,,700,,.T.,,,,,2)


         oPrinter:NewLine()
         FOR nLinha = 1 TO 29
            oPrinter:SetPrc(oPrinter:Prow()+01, 20 )
            oPrinter:Textout(codigoprod+'   '+prod+'    '+'  '+str(precov)+;
               '  '+copias+'  '+cor,.f.)
            skip
         NEXT nLinha
      endi
   endi

oPrinter:EndDoc()
oPrinter:Destroy()

return
Só depois destas 2 funções é que o documento é impresso ou encaminhado ao PDFCreator (ou outro).
Hasse
CP200 / CP500 / Basic / dBase III / dBase IV / Clipper Summer / RTlink / Exospace.
Clipper 5.3b / Blinker 7.0 / CDX com TAG
xHarbour 1.2.1-6604 / Borland C++ (5.5.1) 32 bit / HBmake.
Harbour 3.2.0dev (r1412121623) / MINGW / HBM2 / MiniGui HMG 3.1.4 / IDE (Roberto Lopez).
"Conheça todas as teorias, domine todas as técnicas, mas, quando tocares uma alma humana, seja apenas outra alma humana." (C.G.Jung)
Responder