Renamefile

This function renames a file.

It returns a status: 0 on success; otherwise, it returns a negative code.

Note: This function supersedes System "ren"-PATH-PATH1 on Windows and System "mv"-PATH-PATH1 on Unix. It is faster because it does not fork a process.

Syntax

RETURN_VALUE=RenameFile(PATH, PATH1)

Example

# Renames a log file by changing its extension from .tra to .oldSubprog RENAME_LOG_FILE(LOGFILE_NAME, ERR_CODE)Const Char LOGFILE_NAME()Variable Integer ERR_CODE# Rename the fileERR_CODE=RenameFile(filpath('TMP',LOGFILE_NAME,'tra'),filpath('TMP',LOGFILE_NAME,'old'))End

Return values

ValueExplanation
0Operation succeeded
-20File does not exist
-27Access denied

See also

DelFile