Data width error

Data width error

Postby hag » Fri Jun 17, 2011 5:46 pm

some times customers enter data that when multiplied by other data produces a data width error in the dbf.
Is there a way to see where the width error is and fix on the fly thus eliminating the error message comining up and closing the program.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: Data width error

Postby nageswaragunupudi » Sun Jun 19, 2011 7:52 am

Create your own error handler.
Here is a sample to show datawidth error any where in the software but continues with execution without closing.
Code: Select all  Expand view
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local bOldErr  := ErrorBlock()

   MsgInfo( "Start Test" )
   // Set this at the start of the main module
   ErrorBlock( { |e| MyErrorHandler( e, bOldErr ) } )

   RDDSetDefault( "DBFCDX" )
   DbCreate( "T.DBF", { { "NUM", "N", 2, 0 } } )
   USE T
   APPEND BLANK
   T->NUM := 1000 // This line normally produces runtime error.
   CLOSE DATA
   msginfo( "End of Program" )

return nil

function MyErrorHandler( e, bOldErrHandler )

   if e:SubCode == 1021
      MsgAlert( e:Description + CRLF + ;
                "FIELD : " + e:Operation + CRLF + ;
                ProcName( 2 ) + CRLF + ;
                "Line : " + LTrim( Str( ProcLine( 2 ) ) ) )
      // Decide what the programmer wants to do here
      return .f.
   endif

return Eval( bOldErrHandler, e )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Data width error

Postby hag » Mon Jun 20, 2011 9:45 pm

Rao Thanks for the info. I'll be trying it soon.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 109 guests