The CLEARFILE statement empties the opened section of a file.
Format
CLEARFILE[filevar] |
Parameter(s)
filevar |
File variable to which the file had been opened. If filevar is not specified, the default file variable is used, which is the last file opened without an assigned file variable. |
Description
The CLEARFILE statement deletes all items in a previously opened data file. This statement does not delete the file itself, but it empties the opened section of a file completely.
NOTE |
The CLEARFILE statement cannot be used to empty the file dictionary, nor to delete individual data file items. |
Examples
To clear the data from a file opened to DATAFILE, the code might read:
CLEARFILE DATAFILE |
In the following application, the file TRANS.LOGS contains logs for all transactions during the week. The program fragment shown clears all logs at the request of the operator.
OPEN " TRANS.LOGS " TO LOGFILE ELSE ABORT 201, " PRINTLOG " END PRINT " EMPTY ALL TRANSACTION LOGS (Y OR N) " : INPUT ANSWER IF ANSWER = " Y " THEN CLEARFILE LOGFILE PRINT " ALL TRANSACTION LOGS EMPTIED. " END ELSE PRINT " TRANSACTION LOGS UNTOUCHED. " END |
See Also