Page 2 of 3

Re: grid problem

Posted: Tue Feb 07, 2017 8:16 am
by edk
Hi Franco.
The problem arises when divided by zero or failed to block network access to the database or adding a record.
According to a source in the following cases: EG_ZERODIV, EG_OPEN, EG_APPENDLOCK.
It is important that these events NOT must be at GRID. They can occur anywhere in the program and then GRID will have blank rows, until you close a program.
It was reported on the forum: http://www.hmgforum.com/viewtopic.php?f ... =20#p43507
As he wrote Marek, you have to change ErrorSys.prg and rebuild hmg. Then rebuild own project.
You also do not change ErrorSys, You need add in your own project error handling.
At the beginning of the procedure MAIN:

Code: Select all

OrgErrorBlock := ErrorBlock( { | oError | FrancosError( oError ) } )
and at the end of project

Code: Select all

****************************
FUNCTION FrancosError( oError )
   LOCAL cMessage
   LOCAL cDOSError

   LOCAL n
   Local Ai
   Local lUsr:=.F.

   //Html Arch to ErrorLog
   LOCAL HtmArch, xText

   MEMVAR _HMG_SYSDATA
   #include "hmg.ch"
   #include "error.ch"
   #INCLUDE "COMMON.CH"
   
   // By default, division by zero results in zero
   IF oError:genCode == EG_ZERODIV
      RETURN 0
   ENDIF

   // Set NetErr() of there was a database open error
   IF oError:genCode == EG_OPEN .AND. ;
      oError:osCode == 32 .AND. ;
      oError:canDefault
      NetErr( .T. )
      RETURN .F.
   ENDIF

   // Set NetErr() if there was a lock error on dbAppend()
   IF oError:genCode == EG_APPENDLOCK .AND. ;
      oError:canDefault
      NetErr( .T. )
      RETURN .F.
   ENDIF

   // _HMG_SYSDATA [ 347 ] := .F. <-I think that this line is not needed at all   
   
   HtmArch := Html_ErrorLog()
   cMessage := ErrorMessage( oError )
   IF ! Empty( oError:osCode )
      cDOSError := "(DOS Error " + LTRIM( STR( oError:osCode ) ) + ")"
   ENDIF

   IF ! Empty( oError:osCode )
      cMessage += " " + cDOSError
   ENDIF
   Html_LineText(HtmArch, '<p class="updated">Date:' + Dtoc(Date()) + "  " + "Time: " + Time() )
   Html_LineText(HtmArch, cMessage + "</p>" )
   n := 2
   ai = cmessage + CHR(13) + CHR (10) + CHR(13) + CHR (10)
   WHILE ! Empty( ProcName( n ) )
      xText := "Called from " + ProcName( n ) + "(" + ALLTRIM( STR( ProcLine( n++ ) ) ) + ")" +CHR(13) +CHR(10)
      ai = ai + xText
      Html_LineText(HtmArch,xText)
   ENDDO
   Html_Line(HtmArch)

   lUsr:=ShowError(ai, (oError:canRetry), (oError:canDefault))

   *QUIT

   RETURN lUsr

// [vszakats]

*******************************************
Function ShowError ( ErrorMesssage , lRetry, lDefault)
********************************************
Local nRetMsg, nMilliseconds := 30000 //30 sec
Local nTypeIconButton
	#include "i_MsgBox.ch"
	
	DO CASE
		CASE !lRetry .AND. !lDefault
			nTypeIconButton := MB_OK
		CASE lRetry .AND. lDefault
			nTypeIconButton := MB_ABORTRETRYIGNORE
		CASE lRetry
			nTypeIconButton := MB_RETRYCANCEL
		OTHER
			nTypeIconButton := MB_OK
	ENDCASE
	nTypeIconButton+=MB_ICONERROR + MB_SYSTEMMODAL
	nRetMsg:=MessageBoxTimeout ( ErrorMesssage , 'Program Error ' , nTypeIconButton, nMilliseconds)
	
	DO CASE
		CASE nRetMsg=IDRETRY .OR. nRetMsg=IDTRYAGAIN
			RETURN (.T.)
		CASE nRetMsg=IDIGNORE 
			RETURN (.F.)
		OTHER
			// "Quit" selected
			UnloadAllDll()
			dbcloseall()
			ExitProcess(0)
			QUIT
	ENDCASE

Return .F.
*************************************************************************************************
STATIC FUNCTION ErrorMessage( oError )
   LOCAL cMessage

   // start error message
   cMessage := iif( oError:severity > ES_WARNING, "Error", "Warning" ) + " "

   // add subsystem name if available
   IF ISCHARACTER( oError:subsystem )
      cMessage += oError:subsystem()
   ELSE
      cMessage += "???"
   ENDIF

   // add subsystem's error code if available
   IF ISNUMBER( oError:subCode )
      cMessage += "/" + LTRIM( STR( oError:subCode ) )
   ELSE
      cMessage += "/???"
   ENDIF

   // add error description if available
   IF ISCHARACTER( oError:description )
      cMessage += "  " + oError:description
   ENDIF

   // add either filename or operation
   DO CASE
   CASE !Empty( oError:filename )
      cMessage += ": " + oError:filename
   CASE !Empty( oError:operation )
      cMessage += ": " + oError:operation
   ENDCASE

   RETURN cMessage
Edward.

Re: grid problem

Posted: Tue Feb 07, 2017 11:27 am
by serge_girard
Why is UnloadAllDll() needed and what does it do?
In all my errorsys.prg's there is no UnloadAllDll()...
Should I include it?

Serge

Re: grid problem

Posted: Tue Feb 07, 2017 5:44 pm
by franco
After I modify Errorsys.prg .............. to rebuild do I run buildalllib.bat
Would the francoerror sample work for complete error function for my program.
I have a procedure program would I put all in there .
I do not know what a static function is. Does it mean always available. If so in my procedure program would it need to be static.
Franco

Re: grid problem

Posted: Tue Feb 07, 2017 5:54 pm
by mol
Static function works only in module, where it's defined

Re: grid problem

Posted: Mon Feb 13, 2017 5:36 pm
by franco
After I modified Errorsys.prg .............. and run buildalllib.bat, I have had no more black screens. This was originally very random.
We will stay posted.
Thanks to all and Mol your responses were very helpful.
It is a joy to be associated with such great knowledge.
Franco

Re: grid problem

Posted: Mon Feb 13, 2017 7:10 pm
by mol
Thanks belong to Edward!

Grid problem

Posted: Mon Feb 13, 2017 7:14 pm
by Pablo César
mol wrote: Mon Feb 13, 2017 7:10 pm Thanks belong to Edward!
Thank you both. Good fixing Edward.

I think this could be patched to HMG core. Is it possible, Is feasible Claudio/Rathi ?

Re: grid problem

Posted: Wed May 03, 2017 7:26 pm
by franco
I have new problem in grid.
when in a new window (not main) and in a grid. when X ing out of window with grid I get error msg.
After a day of trying to figure problem I found that if grid has focus when I x out of window there is error.
My window says on release (function closefile()) to close all files open for report.
The error is workarea not in use:DBGOTO
called from DBGOTO(0)
called from getdatagridcelldata(2366)
called from EVENTS(2803)
called from SETFOCUS(0)
called from _HMG_ONHIDEFOCUSMANAGEMENT(5487)
called from EVENTS(3147)
called from DOMESSAGELOOP(0)
called from ACTIVATEWINDOW(5195)
called from DOMETHOD(8102)
called from INVREP2(310) ** this is where I exit window with X.
I could put an exit button but do not have this problem in other areas.
Any thoughts ......... Thanx Franco

Re: grid problem

Posted: Thu May 04, 2017 2:52 pm
by andyglezl
Si tratas con "ON RELEASE DBCLOSEALL()" en vez de tu función como prueba ???

Al parecer tu función ejecuta un DBGOTO() cuando ya cerraste las DB's...
--------------------------------------------------------------------------------------------------
If you try with "ON RELEASE DBCLOSEALL()" instead of your function as test ???

Apparently your function executes a DBGOTO() when you have already closed the DB's ...

Re: grid problem

Posted: Thu May 04, 2017 3:20 pm
by Rathinagiri
Can you please create a small workable sample to demonstrate the problem?