Page 1 of 1

TDosPrint y detectar estado de la impresora

Posted: Sun Apr 02, 2006 10:23 am
by AngelSalom
Buenasssss gente.
Vereis uso tdosprint para imprimir en impresoras de tiquets, el tema es que cuando la impresora no responde (apagada, sin papel, etc...) se me cuelga la aplicación.
Hay forma de averiguar el estado de la impresora antes de lanzar el tdosprint?, generalmente la impresora esta conectada por el puerto paralelo.

Gracias.
Un saludo
Angel Salom
angel@sigev.com

FWH2.7+Harbour+BCC

Posted: Sun Apr 02, 2006 1:42 pm
by Alvaro Urdaneta
Hola Angel,

Yo utilizo en fw/blinker prnstat, pero en fwh no funciona, te anexo el fuente yo no conozco C, si lo puedes poner a funcionar por favor me lo envias. El uso es muy simple unicamente enlazas el OBJ y antes de imprimir e invocas PRNSTAT( 1 ) y te devuelve .T./.F.

Saludos

Posted: Sun Apr 02, 2006 2:11 pm
by Alvaro Urdaneta
ooopsss, no lo puse

#include <ClipApi.h>

CLIPPER PRNSTATUS() // nPort (LPT1 = 1, LPT2 = 2, ...)
{
int Port = IF( PCOUNT() == 0, 0, _parni( 1 ) - 1);
unsigned char iRetVal = 0;

asm {
mov ah, 02h
mov dx, Port
int 17h
mov iRetVal, ah
}

_retl( iRetVal == 0x90 );
}

Saludos

Posted: Sun Apr 02, 2006 2:18 pm
by Antonio Linares
Alvaro,

> int 17h

Las interrupciones (int) no se pueden usar en 32 bits.

Posted: Sun Apr 02, 2006 2:54 pm
by Alvaro Urdaneta
Antonio,

No conozco C, podrias por favor modificarla y generar un OBJ, o existe algo en FWH que funcione parecido, gracias.

Saludos

Posted: Sun Apr 02, 2006 3:07 pm
by Antonio Linares
Alvaro,

Tal vez esta pueda servir:

Code: Select all

CLIPPER PRNSTATUS( PARAMS ) // cPrinter or cPrinterServer --> nStatus
{
	 HANDLE hPrinter = NULL;
	 DWORD cBytesNeeded = 0, cBytesUsed = 0, status = 0;
   PRINTER_INFO_2 * pPrinterInfo = NULL;   	
   
   if( OpenPrinter( _parc( 1 ), &hPrinter, NULL ) )
   {
      GetPrinter( hPrinter, 2, NULL, 0, &cBytesNeeded );
      pPrinterInfo = ( PRINTER_INFO_2 * ) _xgrab( cBytesNeeded );   		
   	  GetPrinter( hPrinter, 2, ( unsigned char * ) pPrinterInfo, cBytesNeeded, &cBytesUsed );
   	  _retnl( pPrinterInfo->Status );
   	  _xfree( pPrinterInfo );
      ClosePrinter( hPrinter );
   }
   else
      _retnl( PRINTER_STATUS_NOT_AVAILABLE );
}      		  
Este es un ejemplo de uso:

Code: Select all

#define PRINTER_STATUS_OK                       0
#define PRINTER_STATUS_PAUSED                   1
#define PRINTER_STATUS_ERROR                    2
#define PRINTER_STATUS_PENDING_DELETION         4
#define PRINTER_STATUS_PAPER_JAM                8
#define PRINTER_STATUS_PAPER_OUT               16
#define PRINTER_STATUS_MANUAL_FEED             32
#define PRINTER_STATUS_PAPER_PROBLEM           64
#define PRINTER_STATUS_OFFLINE                128
#define PRINTER_STATUS_IO_ACTIVE              256
#define PRINTER_STATUS_BUSY                   512
#define PRINTER_STATUS_PRINTING              1024
#define PRINTER_STATUS_OUTPUT_BIN_FULL       2048
#define PRINTER_STATUS_NOT_AVAILABLE         4096
#define PRINTER_STATUS_WAITING               8192
#define PRINTER_STATUS_PROCESSING           16384
#define PRINTER_STATUS_INITIALIZING         32768
#define PRINTER_STATUS_WARMING_UP           65536
#define PRINTER_STATUS_TONER_LOW           131072
#define PRINTER_STATUS_NO_TONER            262144
#define PRINTER_STATUS_PAGE_PUNT           524288
#define PRINTER_STATUS_USER_INTERVENTION  1048576
#define PRINTER_STATUS_OUT_OF_MEMORY      2097152
#define PRINTER_STATUS_DOOR_OPEN          4194304
#define PRINTER_STATUS_SERVER_UNKNOWN     8388608
#define PRINTER_STATUS_POWER_SAVE        16777216

function Main()

   local nStatus := PrnStatus( "LPT1:" )

   MsgInfo( nStatus )

return nil
Y este es el OBJ a reemplazar en FiveHC.lib:
http://hyperupload.com/download/01b93ba ... C.obj.html

Posted: Sun Apr 02, 2006 3:49 pm
by AngelSalom
Fantástico maestro. Funcionó perfecto.

Posted: Sun Apr 02, 2006 4:22 pm
by Alvaro Urdaneta
Antonio,

Funciona perfecto, muchas gracias. Una pregunta, en un futuro esta funcion puede incluirse en FWH ?

Saludos

Posted: Sun Apr 02, 2006 4:50 pm
by AngelSalom
Parece que me precipité. Siempre me devuelve 4096, impresora no lista.
Estaré haciendo algo mal o hay algun problema con la función???
Es una impresora de tiquets conectada directamente al pc por lpt1

Posted: Sun Apr 02, 2006 6:50 pm
by Antonio Linares
Angel,

Es una función nueva en pruebas, probablemente haya que modificarla.

Posted: Tue Aug 08, 2006 2:01 pm
by Olguiver
Tambien realize algunas pruebas pero me marca el mismo error
yo trato de monitorear el estado de una impresora pero conectada por un puerto tcp/ip osea ip_192.25.12.x , y tampoco. real mente lo q necesito es
saber cuando termino el trabajo de imprecion ya q al mandar varios reportes de crystal el sistema aborta. entonces lo q pretendo hacer es monitorear el estatus de la impresion y mandarlo asta q este lista la impresora ya q si mando pocos reportes de crystal directo a la impresora si funciona, pero si mando mas este se cuelga,y manda un extraño mensage de error, cuando mando aimprimir directo el reporte sin previsulizar este, pero algo extraño ya q si hago una previsualizacion no manda el msg de error.

Posted: Wed Nov 08, 2006 4:01 pm
by Ari
function Main()

local nStatus := PrnStatus( "LPT1: ")

MsgInfo( nStatus )

// sempre retorna 4096

return nil

Posted: Wed Nov 08, 2006 4:23 pm
by karinha
Testem este ejemplo de TDOSPRN.PRG Espero que ayude.

http://www.fivewin.com.br/exibedicas.asp?id=496