Page 1 of 1

Strange error when printing that I can't understand..

Posted: Mon Jun 13, 2022 11:05 am
by PedroAlex
hello!

I have a problem in a POS system where I have an application that prints hundreds of receipts a day, but occasionally this error appears and the program interrupts.

here is the error:

------------------------------------------------------------------------------
Registo de Erro de "D:\User\AbRest\AbRest.exe" Data: 01/06/2022 18:47:57

Xbase++ versao : Xbase++ (R) Version 2.00.1176
Sistema Operativo : Windows 10 1809 Build 17763
------------------------------------------------------------------------------
oError:args :
-> VALTYPE: C VALUE: !
oError:canDefault : N
oError:canRetry : Y
oError:canSubstitute: N
oError:cargo : NIL
oError:description : Access to method not allowed in this context
oError:filename :
oError:genCode : 25
oError:operation : qqOut
oError:osCode : 0
oError:severity : 2
oError:subCode : 4402
oError:subSystem : BASE
oError:thread : 5
oError:tries : 14
------------------------------------------------------------------------------
CALLSTACK:
------------------------------------------------------------------------------
Chamado de TALAO_PEDIDO(373)
Chamado de IMPRIMIR_PEDIDOS_NOVOS(213)
Chamado de PROCESSAR_PEDIDOS(96)
Chamado de TRATA_PEDIDO(244)
Chamado de RECEBE_PEDIDO(65)
Chamado de ACTUALIZA_HORA_REST(45)
Chamado de (B)WTPOS(1403)


The Line 373 have this CODE :

Code: Select all

//---------------------------------------------------------------------------------
Function TALAO_PEDIDO( xPorta, xTipo, xSalto, aPedidos, nPrinter, xAnula, BDRate, cNomeOperador, cNomeSeccao, cNomeMesa )
//---------------------------------------------------------------------------------
Local oTalaoPrinter

set console off
set device to printer
set printer on

oTalaoPrinter := XbpPrinter():New():Create( Alltrim(Porta_Printer_Win),, )
Set printer to OBJECT oTalaoPrinter

? Chr(27)+chr(33)+chr(24)   //<<<<<<<<<-------------- Line 373

This code works well on hundreds of invoices made per day.
But unexpectedly 1 or 2 times a day this error occurs.
Does anyone have this kind of problem?

Re: Strange error when printing that I can't understand..

Posted: Mon Jun 13, 2022 12:43 pm
by rdonnay
QQOut() is the function that is called when using the ?? <list> command in the source code.

It appears that your SET PRINTER command failed to establish the proper context for the output.

Re: Strange error when printing that I can't understand..

Posted: Tue Jun 14, 2022 2:05 am
by PedroAlex
Hi Roger,

I appreciate your comment.
But what does this mean
" oError:description : Access to method not allowed in this context "


and do you know where I can find the explanation for this error? " BASE 4402 "

Thanks.

Re: Strange error when printing that I can't understand..

Posted: Tue Jun 14, 2022 5:16 am
by rdonnay
Make sure that the below code creates a proper printer object:

oTalaoPrinter := XbpPrinter():New():Create( Alltrim(Porta_Printer_Win),, )

Use the eXpress++ command WTF to view the object.

WTF oTalaoPrinter

Re: Strange error when printing that I can't understand..

Posted: Wed Jun 15, 2022 3:25 am
by PedroAlex
Hi Roger,

I confirm that the object was created correctly.

I've spent many hours investigating and testing and I can't even get this error on my desktop.
This happens on the client and I know, because the system shows the error message and generates the error.log.
I have to find out what's going on!!

I will continue to investigate..

Thanks

Re: Strange error when printing that I can't understand..

Posted: Wed Jun 15, 2022 5:39 am
by Tom
Output using ? is not allowed if you have a GUI app and your device is the screen. You will get this error if you compile and link this app with the /PM:PM switch:

Code: Select all

FUNCTION Main()
MsgBox('Yo!') // this works
? 'Yo!' // this not
RETURN NIL

PROC APPSYS() ; RETURN
That means: Once in a while, the printer object can't be created. Maybe there is no default printer installed or available.

Re: Strange error when printing that I can't understand..

Posted: Thu Jun 16, 2022 12:04 am
by skiman
Hi,

I always check if the printername, your Alltrim(Porta_Printer_Win) is in the printer list. If the name is not exactly the same, it will not find the printer, and the object will not be created.

Re: Strange error when printing that I can't understand..

Posted: Thu Jun 16, 2022 12:31 am
by Auge_Ohr
hi,
PedroAlex wrote: Mon Jun 13, 2022 11:05 am but occasionally this error appears and the program interrupts.
i wonder that you "think" that Printer is "always ready" ...

you did not "check" Status of Printer before send something to Output

1.) "check" if XbpPrinter Status is XBP_STAT_CREATE
2.) "check" if :printerStatus() is "ready" and "online"

Re: Strange error when printing that I can't understand..

Posted: Sat Jun 18, 2022 1:08 am
by PedroAlex
Hello everybody!

Your messages were important to me because they helped me come up with new solutions to improve this routine.

Thank you all.