grid problem

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

edk
Posts: 103
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 24 times
Been thanked: 44 times

Re: grid problem

Post by edk » Tue Feb 07, 2017 8:16 am

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.

User avatar
serge_girard
Posts: 1727
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 218 times
Been thanked: 36 times
Contact:

Post by serge_girard » Tue Feb 07, 2017 11:27 am

Why is UnloadAllDll() needed and what does it do?
In all my errorsys.prg's there is no UnloadAllDll()...
Should I include it?

Serge

franco
Posts: 183
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Tue Feb 07, 2017 5:44 pm

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

User avatar
mol
Posts: 2740
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 91 times
Been thanked: 31 times
Contact:

Post by mol » Tue Feb 07, 2017 5:54 pm

Static function works only in module, where it's defined

franco
Posts: 183
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Mon Feb 13, 2017 5:36 pm

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

User avatar
mol
Posts: 2740
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 91 times
Been thanked: 31 times
Contact:

Post by mol » Mon Feb 13, 2017 7:10 pm

Thanks belong to Edward!

User avatar
Pablo César
Posts: 4052
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Post by Pablo César » Mon Feb 13, 2017 7:14 pm

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 ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

franco
Posts: 183
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Wed May 03, 2017 7:26 pm

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

User avatar
andyglezl
Posts: 826
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 7 times
Been thanked: 18 times
Contact:

Post by andyglezl » Thu May 04, 2017 2:52 pm

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 ...
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
Rathinagiri
Posts: 5095
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 93 times
Been thanked: 106 times
Contact:

Post by Rathinagiri » Thu May 04, 2017 3:20 pm

Can you please create a small workable sample to demonstrate the problem?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests