# clear-file command

The clear-file command clears the dictionary
or data section of the specified file of all items and retains the
primary file space area.

## Syntax

```
clear-file {(}{data} file.reference{,file.reference}) {(options}
clear-file {(}dict file.reference){(options}
```

## Parameter(s)

| options | c | Scrubs each frame of the file’s primary space, changing every byte in the frame to x'ff'. |
| --- | --- | --- |
| l | No logging—when this option is active, no log of the clear-file is placed in the file of files file item. This can increase performance significantly on temporary files, which are cleared frequently. | |
Warning: The clear-file command
does not require confirmation.

The clear-file command only clears the file, it does not delete it. The file retains
its name, base, and modulo for both dictionary and data sections.

To clear the dictionary section, the dictionary must be specified
before the file reference. If the dictionary is specified, file-defining
items (D-pointers) are not cleared. If no level is specified, the
default is data.

If the file is a pointer file (D-pointer’s
attribute 1 is a dp), then the secondary file space is not returned
to overflow until a full save clears the dirty
bits, and eliminates the deleted items. If the file is an ordinary
data file, then the secondary file space is returned to overflow immediately.

## Example(s)

Removes all items from the data
level of the old.invoices.

```
clear-file data old.invoices
```
Removes all items except D-pointers to data sections from
the dictionary of the invoice.history file.

```
clear-file dict invoice.history
```
Clears the archive data section located in the dictionary
of the invoices file.

```
clear-file data invoices,archive
```

## See also

- [clearfile statement](https://d3codex.com/pickbasic-flashbasic/clearfile-statement/)
- [create-file command](https://d3codex.com/tcl/create-file-command/)
- [delete-file command](https://d3codex.com/tcl/delete-file-command/)
- [File control block](https://d3codex.com/definitions/file-control-block/)
- [open statement](https://d3codex.com/pickbasic-flashbasic/open-statement/)
- [Scrubber](https://d3codex.com/definitions/scrubber/)

---
Source: https://d3codex.com/tcl/clear-file-command/ - part of the D3Codex reference.
