Page 2 of 2

Re: How to include specific items like a record or line number, in your error handler

Posted: Fri Oct 08, 2021 1:48 pm
by HGAutomator
Yes, that's the idea, looks good, thanks Auge.
AUGE_OHR wrote: Fri Oct 08, 2021 10:35 am hi,
HGAutomator wrote: Fri Oct 08, 2021 2:52 am For example, the line number of the text file that was in use. Or the nth field that we're extracting from the text file before the error occurred.

In other words, not just the properties in the Error object, but other variables that were in place at the time of the error, which could make the reason for the error more explicit to the end user.
Ok, got it

i wanted to show a general Way to "react" on Error.
i do read TEXT File with MEMOREAD and use MLCOUNT() / MEMOLINE()

Code: Select all

FUNCTION ReadTXTfile( cFilename ) 
LOCAL cText     := MemoRead( cFilename ) 
LOCAL nMaxLines := MlCount( cText, 80 ) 
LOCAL aLines[ nMaxLines ], n 

   FOR n:=1 TO nMaxLines 
      bError := ERRORBLOCK( { | object | BREAK( object ) } )
      BEGIN SEQUENCE
         cLine := Trim( MemoLine( cText, 80, n ) ) 
         // we are in "this" Errorblock when Code is execute  
         IF .NOT. CheckIt(cLine]) 
           BREAK
         ENDIF
         aLines[ n ] := cLine
      RECOVER USING oError
         lError := .T.
      END SEQUENCE
      ERRORBLOCK( bSaveError )
      IF lError = .T.
         OutPut2Screec("Error Line ",STR(n),a,b,c,d ... )
      ENDIF
      lError := .F. 
   NEXT 
   
RETURN aLines
so it is just a Concept to handle Error Problem