EXCEPTION DEAL

Post Reply
gss200610
Posts: 36
Joined: Sat Jun 19, 2010 10:09 am
Location: Goiania - Goias - Brasil

EXCEPTION DEAL

Post 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?
gss200610
Posts: 36
Joined: Sat Jun 19, 2010 10:09 am
Location: Goiania - Goias - Brasil

Re: EXCEPTION DEAL

Post by gss200610 »

linares or someone?
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: EXCEPTION DEAL

Post by Antonio Linares »

Are you using Harbour or xHarbour ? What version ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
gss200610
Posts: 36
Joined: Sat Jun 19, 2010 10:09 am
Location: Goiania - Goias - Brasil

Re: EXCEPTION DEAL

Post by gss200610 »

xharbour 1.2.1 9746 +FWH 12.01+BCC 5.82.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: EXCEPTION DEAL

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
gss200610
Posts: 36
Joined: Sat Jun 19, 2010 10:09 am
Location: Goiania - Goias - Brasil

Re: EXCEPTION DEAL

Post by gss200610 »

it can be demonstrated, I am grateful. because I'm having more problems. particularly in reading / recording of text files.
Post Reply