CLEARFILE

Top  Previous  Next

 

The CLEARFILE statement clears a file previously opened using the OPEN statement, deleting all records.

 

 

Format

 

CLEARFILE file.var {ON ERROR statement(s)}

 

where

 

file.varis a file variable for an open file.

 

 

The file associated with the file variable will be cleared, deleting all records. In the case of a dynamic file, all overflow space is released and, unless the file has the NO.RESIZE mode enabled, the file returns to its minimum modulus value.

 

The ON ERROR clause is executed if the file cannot be cleared for any reason. The STATUS() function may be used to find the cause of such an error.

 

Note that the CLEARFILE statement executes the clear file trigger function, not the delete trigger function if one is defined.

 

This statement may not be used inside a transaction.

 

 

Example

 

OPEN "STOCK.FILE" TO STOCK THEN

  CLEARFILE STOCK

  CLOSE STOCK

END

ELSE ABORT "Cannot open file"

 

This program fragment opens a file, clears it and then closes the file.