Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

FRename

FRename( cArquivo, cNovoArq, [nParam3], [lChangeCase] ) --> nRet

Renames a file and can move it to another path.

FRenameAdvPL
01 · OVERVIEW

Overview

FRename returns zero on success and -1 on failure. Source files must be closed and wildcards are unsupported. Different directories make it a move, with documented server/workstation and JOB restrictions. The GitHub example uses workstation paths; this adaptation prepares a parameterized callback without moving files. Neither safe overwrite nor atomic move is established by the page. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

FRename( cArquivo, cNovoArq, [nParam3], [lChangeCase] ) --> nRet

Parameters

cArquivo
CharacterRequired

Source with extension and applicable path.

cNovoArq
CharacterRequired

New name and target.

nParam3
AnyOptional

Compatibility: Nil.

lChangeCase
LogicalOptional

Filename case handling according to build/configuration.

Return value

Zero on success; -1 on failure.

03 · PRACTICAL EXAMPLE

Commented example

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

User Function Ed395()
    Local bRename := {|cSource,cTarget| FRename(cSource,cTarget)}
    // Do not evaluate: verify closed files and destination before moving.
Return Nil
Expected result

Callback prepared without renaming or moving. 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. FRename. TDN. Accessed on 2026-10-26.
  2. EURAI. ADVPL/Funcoes/Arquivos de Disco/FRename.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