Functions and Directives

Function FErase() Foundation

Deletes a file.

FErase( <cFilename> ) --> nSuccess
<cFilename> is a character string containing the name of the file to delete, including the drive and path if necessary.

When a file was successfully deleted with FErase(), the function returns the value zero. If the operation fails, the return value is -1 and FError() can be used to retrieve the error code.


The low level file function FErase() deletes a file from the storage media (hard disk, diskette). The file is deleted only if <cFilename> is a valid file name. A successful deletion operation is indicated by the return value zero. If the deletion operation fails, the return value is -1. The error which occurred can be determined from the error code returned from the function FError().

Low level file functions do not recognize either the path set with SET PATH or specified with SET DEFAULT. Therefore, <cFilename> must include a complete file name with drive and path specified. If no drive or path is included in <cFilename>, the file is assumed to reside in the current directory.

If the file to erase is open it must first be closed with FClose() before calling FErase().

// In this example all NTX files in the current path are found 
// using Directory(). The iteration function AEval() passes 
// the respective file information to a code block which calls 
// the function FErase(). This deletes all NTX files. 

#include "" 

   LOCAL aDirectory := Directory("*.NTX") 

   AEval( aDirectory, { |a| FErase( a[ F_NAME ] ) } ) 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.