Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

FCreate

FCreate( cArquivo, [nAtributo], [xParam3], [lChangeCase] ) --> nRet

Creates an empty file or truncates an existing one.

FCreateAdvPL
01 · OVERVIEW

Overview

FCreate is not neutral opening: an existing file is emptied. A valid handle is at least zero; -1 indicates failure. Keep compatibility arguments Nil/zero as documented; lChangeCase depends on build and configuration. The GitHub example creates TEST.TXT without checking creation before closure. This adaptation only prepares an uninvoked callback. A prior File check cannot eliminate races with another process. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

FCreate( cArquivo, [nAtributo], [xParam3], [lChangeCase] ) --> nRet

Parameters

cArquivo
CharacterRequired

Creation name and path.

nAtributo
NumericOptional

Compatibility: Nil or zero.

xParam3
AnyOptional

Compatibility: Nil.

lChangeCase
LogicalOptional

Filename case handling according to build/configuration.

Return value

Handle >= 0; -1 on failure.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"
#Include "Fileio.ch"

User Function Ed380()
    Local bCreate := {|cNewFile| FCreate(cNewFile)}
    // Do not evaluate: FCreate can erase existing content.
Return Nil
Expected result

Block prepared without creating or truncating a file. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • 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.

Related content

REFERENCES
  1. TOTVS. FCreate. TDN. Accessed on 2026-10-26.
  2. EURAI. ADVPL/Funcoes/Arquivos de Disco/FCreate.PRW. universo_do_desenvolvedor_site, commit a5c83e9490302bdb4a0fc5a9d92c2d569a60773c. Exemplo analisado. Accessed on 2026-10-26.
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