Page 1 of 1

EXCEPTION DEAL

Posted: Fri Mar 16, 2012 11:52 am
by gss200610
hello everyone, there are some bars lining the errors such as hb_xgrab requested to allocate zero bytes. among others, I tried to use the try catch and does not always work.
the executable stops working. in C + + there is a throw to handle exceptions,
because in my application to each sale item to read a certain amount of text file to add the item sold and rewrite the updated value in text file. More often nothing of the error hb_xgrab requested to allocate zero bytes and the application closes and the User loses all sales in progress.

there is a way to treat it, to block these errors?

Re: EXCEPTION DEAL

Posted: Sat Mar 17, 2012 7:44 pm
by gss200610
linares or someone?

Re: EXCEPTION DEAL

Posted: Sun Mar 18, 2012 12:16 pm
by Antonio Linares
Are you using Harbour or xHarbour ? What version ?

Re: EXCEPTION DEAL

Posted: Sun Mar 18, 2012 3:22 pm
by gss200610
xharbour 1.2.1 9746 +FWH 12.01+BCC 5.82.

Re: EXCEPTION DEAL

Posted: Mon Mar 19, 2012 7:36 am
by Antonio Linares
My advise is that you migrate to Harbour. That will surely fix it.

Besides that we can use C try... except exceptions in Harbour/xHarbour, but thats not the right way to solve it. Here you an example to trap an exception when calling SysRefresh():

Code: Select all

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>
#include <stdio.h>

BOOL SysRefresh( void );

HB_FUNC( NOGPF )
{
   __try
   {
      hb_retl( SysRefresh() );
   }
   __except ( ( hb_retl( TRUE ), TRUE ) )
   {} 
}

#pragma ENDDUMP 
As you can jump from low level to high level, you could invoke your Main() from such C routine, so your entire app execution will be controlled by that C++ try ... except code :-) I can show you an example if you don't know how to do it

Re: EXCEPTION DEAL

Posted: Mon Mar 19, 2012 11:19 am
by gss200610
it can be demonstrated, I am grateful. because I'm having more problems. particularly in reading / recording of text files.