Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

FWrite

FWrite(nHandle,cBuffer,[nBytes]) -> nWritten

Writes bytes through an open file handle.

FWriteAdvPL
01 · OVERVIEW

Overview

Takes a writable handle from FCreate/FOpen. Return value is the number actually written; zero or partial writes are not complete success. This helper receives an already-open handle without creating, truncating or closing a caller-owned file. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

FWrite(nHandle,cBuffer,[nBytes]) -> nWritten

Parameters

nHandle
NumericRequired

Open writable handle.

cBuffer
CharacterRequired

Bytes to write.

nBytes
NumericOptional

Number of bytes.

Return value

Number of bytes written.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed449()
    // Helper receives a caller-owned test handle.
    Local bWrite := {|nHandle,cBuffer| FWrite(nHandle,cBuffer,Len(cBuffer))}
    ConOut(ValType(bWrite))
Return Nil
Expected result

Prepares block B; compare its result with Len(cBuffer) on execution. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check FError after failure and define partial-write handling. Caller remains responsible for closing.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. FWrite. 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