RE:Cursores.... ¿cómo se definen?
aca va una ayudita
------------------------------------------------------------------------------------
function CONVERTIR
lparameters HexValue
PRIVATE i, Valor, estado
estado = 0
FOR i = 4 TO 1 STEP -1
S = SUBSTR(HexValue, i, 1)
Valor = ASC (S)
IF ( Valor >= ASC("A") .AND. Valor <= ASC("F") )
Valor = Valor - ASC("A") + 10
else
IF ( Valor >= ASC("a") .AND. Valor <= ASC("f") )
Valor = Valor - ASC("a") + 10
else
IF ( Valor >= ASC("0") .AND. Valor <= ASC("9") )
Valor = Valor - ASC("0")
ELSE
RETURN(-1)
endif
endif
ENDIF
estado =estado + Valor * (16 ** ( 4 - i ))
next
RETURN estado
-------------------------------------------------------------------------------------
function VERIFICAR
lparameters resp,comando
PRIVATE Origen, OffsetSep, i, c, nroerror, resultado
DECLARE FiscalErrors [16]
DECLARE PrinterErrors[16]
FiscalErrors[1] = "Error en chequeo de memoria fiscal"
FiscalErrors[2] = "Error en chequeo de la memoria de trabajo"
FiscalErrors[3] = "Carga de bateria baja"
FiscalErrors[4] = "Comando desconocido"
FiscalErrors[5] = "Datos no validos en un campo"
FiscalErrors[6] = "Comando no valido para el estado fiscal actual"
FiscalErrors[7] = "Desborde del total"
FiscalErrors[8] = "Memoria fiscal llena"
FiscalErrors[9] = "Memoria fiscal a punto de llenarse"
FiscalErrors[10] = ""
FiscalErrors[11] = ""
FiscalErrors[12] = "Error en ingreso de fecha"
FiscalErrors[13] = "Recibo fiscal abierto"
FiscalErrors[14] = "Recibo abierto"
FiscalErrors[15] = "Factura abierta"
FiscalErrors[16] = ""
PrinterErrors[1] = ""
PrinterErrors[2] = ""
PrinterErrors[3] = "Error de Impresora"
PrinterErrors[4] = "Impresora Offline"
PrinterErrors[5] = "Falta papel del diario"
PrinterErrors[6] = "Falta papel de tickets"
PrinterErrors[7] = "Buffer de Impresora lleno"
PrinterErrors[8] = ""
PrinterErrors[9] = ""
PrinterErrors[10] = ""
PrinterErrors[11] = ""
PrinterErrors[12] = ""
PrinterErrors[13] = ""
PrinterErrors[14] = ""
PrinterErrors[15] = ""
PrinterErrors[16] = ""
resultadop=substr(Resp,1,4)
* Convierte en hexa el status del impresor
PrinterStatus = thisform.CONVERTIR(resultadop)
if PrinterStatus < 0
RETURN(-1)
endif
* Analiza los bits comenzando del menos significativo
for i = 1 to 16
if ( INT (PrinterStatus % 2) == 1 )
if ( LEN (PrinterErrors[i]) > 0 )
thisform.mensajes(PrinterErrors[i],10)
SET PRINTER TO ERROR.P
set console off
set print on
?'Error....: '+PrinterErrors[i]
?'Comando..: '+comando
?'Respuesta: '+Resultadop
?'-2'
set print off
set console on
SET PRINTER TO
RETURN(-2)
endif
endif
PrinterStatus = PrinterStatus / 2
next
resultadof=substr(resp,6,4)
* Convierte en hexa el status fiscal
FiscalStatus = thisform.CONVERTIR(resultadof)
if FiscalStatus < 0
RETURN(-1)
endif
* Analiza los bits comenzando del menos significativo
for i = 1 to 16
if ( INT (FiscalStatus % 2) == 1 )
if ( LEN (FiscalErrors[i]) > 0 )
if .not.(i=6.or.i=9.or.i=13.or.i=14.or.i=15)
thisform.mensajes(FiscalErrors[i],10)
SET PRINTER TO ERROR.F
set console off
set print on
?'Error....: '+FiscalErrors[i]
?'Comando..: '+comando
?'Respuesta: '+Resultadof
?'-3'
set print off
set console on
SET PRINTER TO
RETURN(-3)
else
if i=6
SET PRINTER TO ERROR.F
set console off
set print on
?'Error....: '+FiscalErrors[i]
?'Comando..: '+comando
?'Respuesta: '+Resultadof
?'-4'
set print off
set console on
SET PRINTER TO
RETURN(-4)
endif
endif
endif
endif
FiscalStatus = FiscalStatus / 2
next
return(0)