AUGE_OHR wrote: ↑Fri Oct 08, 2021 10:35 am hi,Ok, got itHGAutomator 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.
i wanted to show a general Way to "react" on Error.
i do read TEXT File with MEMOREAD and use MLCOUNT() / MEMOLINE()
so it is just a Concept to handle Error ProblemCode: 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
How to include specific items like a record or line number, in your error handler
Moderator: Rathinagiri
-
HGAutomator
- Posts: 202
- Joined: Thu Jul 16, 2020 5:42 pm
- DBs Used: DBF
Re: How to include specific items like a record or line number, in your error handler
Yes, that's the idea, looks good, thanks Auge.