FError
FError() --> nRetRetrieves the last file-operation diagnostic.
Overview
FError returns a code for the last file operation, with zero indicating no error. Capture it immediately after failure; closing another handle first can change the diagnostic reference. Official descriptions vary by platform, so codes are not universal errno values. The example deliberately closes invalid handle -1 without touching a valid file. FClose documentation confirms this case, but no portable numeric error is assumed here. (TOTVS, n.d., ref. 1)
Syntax
FError() --> nRetReturn value
Numeric code; zero indicates no error.
Commented example
#Include "Protheus.ch"
#Include "Fileio.ch"
User Function Ed381()
Local nError
// -1 is not a valid handle; inspect the diagnostic immediately.
If !FClose(-1)
nError := FError()
ConOut(cValToChar(nError))
EndIf
Return NilImplementation-specific failure code; no valid handle closed. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Check path, permissions, platform and handle ownership. Close only handles obtained by this routine, including complete-application error handling.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.