cArqFilename with path when needed.
AdvPL GuideFOpen( cArq, [nModo], [xParam3], [lChangeCase] ) --> nRetOpens an existing file and returns its handle.
FOpen does not create missing files. nModo combines Fileio.ch access and sharing flags; this example chooses shared read-only access whereas the community source requests read/write. Handle zero is valid and -1 is failure. The page states lookup does not follow AdvPL Set Default/Set Path; lChangeCase matters for case-sensitive names. editorial-test.txt must exist in the test context; the fragment closes only its own handle. (TOTVS, n.d., ref. 1)
FOpen( cArq, [nModo], [xParam3], [lChangeCase] ) --> nRetcArqFilename with path when needed.
nModoFileio.ch access + sharing.
xParam3Compatibility: Nil.
lChangeCaseFilename case handling according to build/configuration.
Handle >= 0; -1 on failure.
#Include "Protheus.ch"
#Include "Fileio.ch"
User Function Ed388()
Local nHandle := -1
Local nError := 0
// Pre-existing fictional file in the test context; shared reading.
nHandle := FOpen("editorial-test.txt", FO_READ + FO_SHARED)
If nHandle < 0
nError := FError()
ConOut(cValToChar(nError))
Else
ConOut("File opened for reading")
If !FClose(nHandle)
ConOut(cValToChar(FError()))
EndIf
EndIf
Return NilOpen message followed by closure, or a failure code. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use
Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.