# clearfile statement

The clearfile statement deletes all
items in the specified file variable previously opened with an open statement.

## Syntax

```
clearfile {file.var}
```

## Parameter(s)

| file.var | Specifies the file in which all items are to be deleted. |
| --- | --- |

## Description

The default *file.var* is cleared if no *file.var* is specified. This
statement works like the TCL clear-file command.

The file is not deleted, but all nonfile type items within the
data file or dictionary are deleted. The file retains the same base
and modulo. If the dictionary is specified in the associated open statement that defines the file variable, the dictionary
of the file is cleared. If data is specified in
the associated open statement, the data section
of the file is cleared. If neither is specified in the associated open statement, the data section of the file is cleared.

CAUTION: Once started, it clears the file to completion.
The process cannot be stopped.

## See also

- [begin work statement](https://d3codex.com/pickbasic-flashbasic/begin-work-statement/)
- [clear-file command](https://d3codex.com/tcl/clear-file-command/)
- [Default File Variables](https://d3codex.com/pickbasic-flashbasic/default-file-variables/)
- [File reference (Access Query Language)](https://d3codex.com/access/file-reference-access-query-language/)
- [File variable](https://d3codex.com/pickbasic-flashbasic/file-variable/)
- [matread statement](https://d3codex.com/pickbasic-flashbasic/matread-statement/)
- [open statement](https://d3codex.com/pickbasic-flashbasic/open-statement/)
- [Processing codes](https://d3codex.com/processingcodes/processing-codes/)
- [read statement](https://d3codex.com/pickbasic-flashbasic/read-statement/)
- [readnext statement](https://d3codex.com/pickbasic-flashbasic/readnext-statement/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [Variables](https://d3codex.com/pickbasic-flashbasic/variables/)

---
Source: https://d3codex.com/pickbasic-flashbasic/clearfile-statement/ - part of the D3Codex reference.
