isprinter????

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

Moderador: Moderadores

Avatar do usuário
janio
Colaborador
Colaborador
Mensagens: 1846
Registrado em: 06 Jul 2004 07:43
Localização: UBAJARA - CE

isprinter????

Mensagem por janio »

Pessoal,

A função isprinter() funciona no xharbour?

Janio
fui...
e-mail:janioaguiar@yahoo.com.br
msn: janio_aguiar@hotmail.com
xHarbour1.2.1/Harbour3.2 + wvg + hwgui + Mediator + MySql
MARINI
Usuário Nível 3
Usuário Nível 3
Mensagens: 288
Registrado em: 06 Jul 2004 08:06
Localização: Pindamonhangaba SP

Mensagem por MARINI »

Na documentação diz que sim. Veja:

xHb Function: ISPRINTER
Determine whether LPT1 is ready
• Syntax:
ISPRINTER() --> lReady
• Scope:

• Category:
Printer
• Arguments:
None
• Return value:
ISPRINTER() returns true (.T.) if LPT1 is ready; otherwise, it returnsfalse (.F.).
• Description:
ISPRINTER() is a printer function that determines whether the parallelport (LPT1) is online and ready to print. ISPRINTER() ishardware-dependent and, therefore, only works on IBM BIOS compatiblesystems.
You can check ISPRINTER() to make sure the printer is ready before youbegin a print operation; however, if an error occurs during the printoperation, a runtime error is generated.
• Examples:
0
• Files:
Library is rtl.lib, source is isprint.c
• See also:
GETPRINTERS
Sds
Marini
Stanis Luksys
Colaborador
Colaborador
Mensagens: 1329
Registrado em: 18 Jun 2005 03:04
Localização: São Paulo
Contato:

Mensagem por Stanis Luksys »

No (x)harbour funciona, não funciona no XP... Em todos outros Windows roda normal...
Stanis Luksys
sites.google.com/hblibs

Apoiar e se utilizar de projetos opensource não é uma questão de boicote, mas sim de liberdade.
Utilize, aprimore e distribua.
Avatar do usuário
Antonio
Usuário Nível 3
Usuário Nível 3
Mensagens: 347
Registrado em: 14 Ago 2003 17:33
Localização: Sao Paulo - SP
Contato:

Mensagem por Antonio »

Utilize as funções: PRINTEREXISTS(), GETPRINTERS(), GETDEFAULTPRINTER(), XISPRINTER(), PRINTERPORTTONAME()
Antonio Carlos
Harbour 3.2 (20180213)
Hwgui 2.20 3b | PostGresql 9.5 | ADO/ODBC
Avatar do usuário
janio
Colaborador
Colaborador
Mensagens: 1846
Registrado em: 06 Jul 2004 07:43
Localização: UBAJARA - CE

Mensagem por janio »

Antonio escreveu:Utilize as funções: PRINTEREXISTS(), GETPRINTERS(), GETDEFAULTPRINTER(), XISPRINTER(), PRINTERPORTTONAME()
Olá Antonio,

Obrigado por responder....

Se não for pedir muito.... vc poderia colocar aqui uma pequena descrição de para que serve cada uma das funções q vc mencionou?

Um abraço,

Janio
fui...
e-mail:janioaguiar@yahoo.com.br
msn: janio_aguiar@hotmail.com
xHarbour1.2.1/Harbour3.2 + wvg + hwgui + Mediator + MySql
Avatar do usuário
Antonio
Usuário Nível 3
Usuário Nível 3
Mensagens: 347
Registrado em: 14 Ago 2003 17:33
Localização: Sao Paulo - SP
Contato:

Mensagem por Antonio »

Janio

Basicamente é isso.

prn:= GetPrinters()
prn retorna um array com o nome das impressoras instaladas, se for passado o parametro <lPorts> como .T. um 2º array sera retornado {Nome da impressora, Porta da Impressora}


cPrinter := GETDEFAULTPRINTER()
Retorna o nome da impressora padrão.

XISPRINTER()
Não encontrei informações, mas creio que seja uma especie de SPRINTER() adequado ao SO Windows.

? PRINTEREXISTS("HP LaserJet 1200 Series PCL")
Retorna .T. se a impressora passada estiver instalada.

IF EMPTY( PRINTERPORTTONAME( "lpt1", .T. ) )
Alert( "No printer installed - cannot continue" )
QUIT
ENDIF

Pode ser passado uma porta COM tambem.


em xharbour\doc existem documentos.txt dos quais podem ser geradas a documentação do xharbour, tem uns .BATS que fazem isso. De uma olhadinha.
Antonio Carlos
Harbour 3.2 (20180213)
Hwgui 2.20 3b | PostGresql 9.5 | ADO/ODBC
Avatar do usuário
janio
Colaborador
Colaborador
Mensagens: 1846
Registrado em: 06 Jul 2004 07:43
Localização: UBAJARA - CE

Mensagem por janio »

Antonio, brigadão por responder...

Migrei, quer dizer, ainda tô migrando de clipper para xharbour e tem muitas coisas que ainda não sei direito...

Lá vai outra dúvida: :-o

Todos nós sabemos da diculdade de se imprimir em impressoras USB no CLIPPER. No xharbour (console) tem esse problema também, sendo necessário o uso de um programa externo pra poder efetuar impressão em impressoras USB?

Janio
fui...
e-mail:janioaguiar@yahoo.com.br
msn: janio_aguiar@hotmail.com
xHarbour1.2.1/Harbour3.2 + wvg + hwgui + Mediator + MySql
Avatar do usuário
Antonio
Usuário Nível 3
Usuário Nível 3
Mensagens: 347
Registrado em: 14 Ago 2003 17:33
Localização: Sao Paulo - SP
Contato:

Mensagem por Antonio »

Ola Janio.

Existe a Classe PRINTDOS e tambem a WIN32PRN esta acessa direto o dispositivo USB.


PrintDos

Código: Selecionar todos

Function TestDosClipper(oTest)
Local oPrinter

   SET PRINTER TO oTest OF oPrinter

   @  0,  1 PSAY  "LINE 0 COL 1"  OF oPrinter
   @ 10, 11 PSAY "LINE 10 COL 11" OF oPrinter
   @ 10, 31 PSAY "LINE 10 COL 31" OF oPrinter
   @ 14, 21 PSAY "LINE 14 COL 21" OF oPrinter
   @ 30, 34 PSAY "LINE 30 COL 34" OF oPrinter
   @ wProw(oPrinter), wPCol(oPrinter) PSAY "LINE "+STR(wProw(oPrinter))+ " COL "+STR(wPcol(oPrinter)) OF oPrinter
   @ 40, 24 PSAY "11222333000144" PICTURE "@r 99.999.999/9999-99"  OF oPrinter
   @ wprow(oPrinter)+1, wPcol(oPrinter) PSAY "Valor" OF oPrinter
   @ wprow(oPrinter), wPcol(oPrinter)   PSAY 996659.85 PICTURE "@E 999,999,999.99" OF oPrinter
   @ wprow(oPrinter), wPcol(oPrinter)+1 PSAY  22.11  OF oPrinter
   @ wprow(oPrinter), wPcol(oPrinter)+1 PSAY DATE() OF oPrinter
   
   EJECT OF oPrinter
   
   @ 01, 10 PSAY "End of printer text, the PrintDos Class - Style Clipper" OF oPrinter

   wSetPrc(0,0,oPrinter)
   
   END PRINTER oPrinter

   If !Empty(oTest)
     OpenRel(oTest)
   EndIF  

Endif

Return Nil
Win32Prn

Código: Selecionar todos


#define FORM_A4 9

#define PS_SOLID            0

#define RGB( nR,nG,nB )   ( nR + ( nG * 256 ) + ( nB * 256 * 256 ) )

#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, cBMPFile:= SPACE( 40 )
  LOCAL aPrn:= GetPrinters()
  LOCAL GetList:= {}
  CLS
  IF EMPTY(aPrn)
    Alert("No printers installed - Cannot continue")
    QUIT
  ENDIF
  DO WHILE !EMPTY(nPrn)
    CLS
    @ 0,0 SAY 'Win32Prn() Class test program. Choose a printer to test'
    @ 1,0 SAY 'Bitmap file name' GET cBMPFile PICT '@!K'
    READ
    @ 2,0 TO maxRow(),maxCol()
    nPrn:= ACHOICE(3,1,maxRow()-1,maxCol()-1,aPrn,.T.,,nPrn)
    IF !EMPTY(nPrn)
        PrnTest(aPrn[nPrn], cBMPFile)
    ENDIF
  ENDDO
  RETURN(NIL)

STATIC FUNCTION PrnTest(cPrinter, cBMPFile)
  LOCAL oPrinter:= Win32Prn():New(cPrinter), aFonts, x, nColFixed, nColTTF, nColCharSet
  oPrinter:Landscape:= .F.
  oPrinter:FormType := FORM_A4
  oPrinter:Copies   := 1
  IF !oPrinter:Create()
    Alert("Cannot Create Printer")
  ELSE
    IF !oPrinter:startDoc('Win32Prn(Doc name in Printer Properties)')
      Alert("StartDoc() failed")
    ELSE
      oPrinter:SetPen(PS_SOLID, 1, RED)
      oPrinter:Bold(800)
      oPrinter:TextOut(oPrinter:PrinterName+': MaxRow() = '+STR(oPrinter:MaxRow(),4)+'   MaxCol() = '+STR(oPrinter:MaxCol(),4))
      oPrinter:Bold(0)     // Normal
      oPrinter:NewLine()
      oPrinter:TextOut('   Partial list of available fonts that are available for OEM_')
      oPrinter:NewLine()
      oPrinter:UnderLine(.T.)
      oPrinter:Italic(.T.)
//      oPrinter:SetFont('Courier New',7,{3,-50})  // Compressed print
      nColFixed:= 40 * oPrinter:CharWidth
      nColTTF  := 48 * oPrinter:CharWidth
      nColCharSet  := 60 * oPrinter:CharWidth
      oPrinter:TextOut('FontName')
      oPrinter:SetPos(nColFixed)
      oPrinter:TextOut('Fixed?')
      oPrinter:SetPos(nColTTF)
      oPrinter:TextOut('TrueType?')
      oPrinter:SetPos(nColCharset)
      oPrinter:TextOut('CharSet#',.T.)
      oPrinter:NewLine()
      oPrinter:Italic(.F.)
      oPrinter:UnderLine(.F.)
      aFonts:= oPrinter:GetFonts()
      oPrinter:NewLine()
      FOR x:= 1 TO LEN(aFonts) STEP 2
        oPrinter:CharSet(aFonts[x,4])
        IF oPrinter:SetFont(aFonts[x,1])       // Could use "IF oPrinter:SetFontOk" after call to oPrinter:SetFont()
          IF oPrinter:FontName == aFonts[x,1]  // Make sure Windows didn't pick a different font
            oPrinter:TextOut(aFonts[x,1])
            oPrinter:SetPos(nColFixed)
            oPrinter:TextOut(IIF(aFonts[x,2],'Yes','No'))
            oPrinter:SetPos(nColTTF)
            oPrinter:TextOut(IIF(aFonts[x,3],'Yes','No'))
            oPrinter:SetPos(nColCharSet)
            oPrinter:TextOut(STR(aFonts[x,4],5))
            oPrinter:SetPos(oPrinter:LeftMargin, oPrinter:PosY + (oPrinter:CharHeight*2))
            IF oPrinter:PRow() > oPrinter:MaxRow() - 10  // Could use "oPrinter:NewPage()" to start a new page
              EXIT
          ENDIF
          ENDIF
        ENDIF
        oPrinter:Line(0, oPrinter:PosY+5, 2000, oPrinter:PosY+5)
      NEXT x
      oPrinter:SetFont('Lucida Console',8,{3,-50})  // Alternative Compressed print
      oPrinter:CharSet(0)  // Reset default charset
      oPrinter:Bold(800)
      oPrinter:NewLine()
      oPrinter:TextOut('This is on line'+STR(oPrinter:Prow(),4)+', Printed bold, ' )
      oPrinter:TextOut(' finishing at Column: ')
      oPrinter:TextOut(STR(oPrinter:Pcol(),4))
      oPrinter:SetPrc(oPrinter:Prow()+3, 0)
      oPrinter:Bold(0)
      oPrinter:TextOut("Notice: UNDERLINE only prints correctly if there is a blank line after",.T.)
      oPrinter:TextOut("        it. This is because of ::LineHeight and the next line",.T.)
      oPrinter:TextOut("        printing over top of the underline. To avoid this happening",.T.)
      oPrinter:TextOut("        you can to alter ::LineHeight or use a smaller font")
      oPrinter:NewLine()
      oPrinter:NewLine()
      oPrinter:SetFont('Lucida Console',18, 0)  // Large print
      oPrinter:SetColor( GREEN )
      oPrinter:TextOut("Finally some larger print")
      oPrinter:Box(  0, oPrinter:PosY+100, 100, oPrinter:PosY+200)
      oPrinter:Arc(200, oPrinter:PosY+100, 300, oPrinter:PosY+200)
      oPrinter:Ellipse(400, oPrinter:PosY+100, 500, oPrinter:PosY+200)
      oPrinter:FillRect(600, oPrinter:PosY+100, 700, oPrinter:PosY+200, RED)

//    To print a barcode;
//    Replace 'BCod39HN' with your own bar code font or any other font
//      oPrinter:TextAtFont( oPrinter:MM_TO_POSX( 30 ) , oPrinter:MM_TO_POSY(60 ), '1234567890', 'BCod39HN', 24, 0 )
//
      PrintBitMap( oPrinter, cBMPFile )

      oPrinter:EndDoc()
    ENDIF
    oPrinter:Destroy()
  ENDIF
  RETURN(NIL)


procedure PrintBitMap( oPrn, cBitFile )
  LOCAL oBMP

  IF EMPTY( cBitFile )
    *
  ELSEIF !FILE( cBitFile )
    Alert( cBitFile + ' not found ' )
  ELSE
    oBMP:= Win32BMP():new()
    IF oBmp:loadFile( cBitFile )

      oBmp:Draw( oPrn,  { 200,200, 2000, 1500 } )

      // Note: Can also use this method to print bitmap
      //   oBmp:Rect:= { 200,2000, 2000, 1500 }
      //   oPrn:DrawBitMap( oBmp )

    ENDIF
    oBMP:Destroy()
  ENDIF
  RETURN
Antonio Carlos
Harbour 3.2 (20180213)
Hwgui 2.20 3b | PostGresql 9.5 | ADO/ODBC
microvolution
Usuário Nível 5
Usuário Nível 5
Mensagens: 1231
Registrado em: 02 Set 2011 22:17
Contato:

isprinter????

Mensagem por microvolution »

primeiramente boa tarde!
postei uma dúvida noutro post, mas, como ele é muito antigo, e, não sei se alguém irá responder... tomei a liberdade para postar a mesma dúvida aqui, pois é o mesmo assunto: ISPRINTER().
Então, desde 1998 até 2015 (antes da migração para clipper) a função ISPRINTER (que verifica se uma imprssora LPTx existe) funcionava perfeitamente...
E, como é este funcionava para mim?
Bom, está no meu código assim:

Código: Selecionar todos

do while (lastkey () <> K_ESC .and. .not. isprinter ())
acontece que após migrar para harbour 3.4.0, não mais funciona corretamente.
E, funcionar corretamente pra mim sempre foi assim:
se existir impressora - .t.
se não existir impressora - .f.
se a impressora estiver instalada e ligada - .t.
se a impressora estiver instalada e desligada - .f.
se a impressora existir, ligada, mas o cabo desconectado - .f.
Então já tentei de tudo... tanto em windows XP (32), windows 7 (32 bits) e agora em windows 10 (64 bits)... o retorno é sempre o mesmo (.f.) não há condição que funcione.
Testei até este exemplo
marcos.gurupi escreveu:PrinterPortToName("LPT1:",.T.)
e o resultado é assim:
se existir uma impressora instalada e ligada --> .t.
se existir uma impressora instalada e desligada --> .t.
se não existir uma impressora instalada aí sim --> .f.

Então, as 2 primeiras informações não estão corretas...
bom já tentei de tudo:

Código: Selecionar todos

      // do while (lastkey () <> K_ESC .and. .not. isprint ())
      // do while (lastkey () <> K_ESC .and. .not. ft_IsPrint ())
      // do while (lastkey () <> K_ESC .and. .not. isprinter ())
      // do while (lastkey () <> K_ESC .and. .not. hb_IsPrinter ())
      do while (lastkey () <> K_ESC .and. .not. EMPTY( PRINTERPORTTONAME( "lpt1:", .T. ) ) ) 
      // do while (lastkey () <> K_ESC .and. .not. sprintf ())
      // do while (lastkey () <> K_ESC .and. .not. PrintReady (1))
      // do while (lastkey () <> K_ESC .and. .not. PrinterExists ())
      // do while (lastkey () <> K_ESC .and. .not. PrinterPortToname ())
      // do while (lastkey () <> K_ESC .and. .not. XIsPrinter(1))
      // do while (lastkey () <> K_ESC .and. .not. NetPrinter())
      // do while (lastkey () <> K_ESC .and. .not. ERR_print_errors(BIO_new_fd( 1, HB_BIO_NOCLOSE )))
todos os códigos acima, dão sempre a mesma coisa... não importa se a impressora está ligada ou não... se houver ela instalada, retorna como .t.
E, antes de migrar, só retornava .t. se a impressora estivesse ligada, e, no caso fiz um loop que enquanto o usuário não pressiona a tecla ESC ou não resolva o problema da impressora o do/while não é encerrado.
Você ou alguém pode ajudar?
Grato,
MICROVOLUTION - 16 anos Evoluindo Com Você!


Você já leu a Bíblia hoje?
João 3:16 - Porque Deus amou ao mundo de tal maneira que deu seu Único Filho para que todo aquele que nEle crê não pereça mas tenha a Vida Eterna!
Responder