Usina BRAdvPL Guide
Sign in
← All topics
CLASSUnder review

FWFileReader

FWFileReader():New(cFileName, [xBreakLine])

Reads text files line by line with buffering.

FWFileReaderAdvPL
01 · OVERVIEW

Overview

Use HasLine with GetLine: EOF is documented for byte reading. Buffered lines can remain after physical EOF. FullRead and GetAllLines need memory planning; getBytesRead counts bytes fetched into the buffer. The example receives a prepared complete path and counts lines without logging contents. Close follows successful opening on the normal path; application exception handling must ensure cleanup on unexpected failures too. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

FWFileReader():New(cFileName, [xBreakLine])

Parameters

cFileName
CharacterRequired

Complete test path in the execution context.

xBreakLine
CharacterOptional

Optional line separator.

Methods

Open / CloseLogical opening; close after success.o:Open() / o:Close()
HasLineChecks lines in file or buffer.o:HasLine() --> lHasLine
GetLineReads the next line; option preserves its break.o:GetLine([lReturnCr]) --> cLine
FullReadReads all content; respect string limits.o:FullRead() --> cBuffer
03 · PRACTICAL EXAMPLE

Commented example

// Fragment: cPath is a validated complete test path.
oReader := FWFileReader():New(cPath)
nLines := 0
If oReader:Open()
    // Use HasLine to consume GetLine.
    While oReader:HasLine()
        cLine := oReader:GetLine()
        nLines++
    EndDo
    oReader:Close()
EndIf
FreeObj(oReader)
Expected result

Count depends on the file; no fixed line count. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check LIB version, lifecycle and context before integration. These methods are a documented subset rather than the complete API.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. FWFileReader. TDN. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha