# Default File Variables

The following statements make use of a feature known as default file
 variables:

clearfile

delete

matread

matreadu

matwrite

matwriteu

open

read

readu

readv

readvu

release

select

write

writev

writevu

Note: Most experts agree that
use of this feature should be avoided as it makes program maintenance
more difficult, but here is a discussion of how they work.

When a file is opened with an open statement,
it is usually assigned to a file variable for referencing the file
later in the program with any of the above statements. This takes
the general form:

```
open "customers" to customer.file else...
```
The operative word here is to. In this case, it assigns the actual location
 (represented internally as a base, modulo and separation) to the customer file variable. Later
 in the program, when an item is read from the file, the file variable displays in the
 appropriate form of a read statement, as in the form:

```
read customer.item from customer.file else...
```
Here, the operative word is from. With
default file variables, nothing is explicitly assigned during the open statement, as in the form:

```
open "customers" else...
```
Therefore, any subsequent attempt to read from or write
to the file does not require the file variable reference, as illustrated
in the form:

```
read customer.item else...
```
There can be only one default file variable in a BASIC
program. Any subsequent file needed for input or output must have
an explicitly assigned file variable during the open statement, or it takes the place of the default file.

## See also

- [base](https://d3codex.com/attributedefiningitem/base/)
- [clear statement](https://d3codex.com/pickbasic-flashbasic/clear-statement/)
- [clearfile statement](https://d3codex.com/pickbasic-flashbasic/clearfile-statement/)
- [close statement](https://d3codex.com/pickbasic-flashbasic/close-statement/)
- [common statement](https://d3codex.com/pickbasic-flashbasic/common-statement/)
- [convert statement](https://d3codex.com/pickbasic-flashbasic/convert-statement/)
- [convert() function](https://d3codex.com/pickbasic-flashbasic/convert-function/)
- [Data representation](https://d3codex.com/pickbasic-flashbasic/data-representation/)
- [delete statement](https://d3codex.com/pickbasic-flashbasic/delete-statement/)
- [clearfile statement](https://d3codex.com/pickbasic-flashbasic/clearfile-statement/)
- [matread statement](https://d3codex.com/pickbasic-flashbasic/matread-statement/)
- [matwrite statement](https://d3codex.com/pickbasic-flashbasic/matwrite-statement/)
- [matwriteu statement](https://d3codex.com/pickbasic-flashbasic/matwriteu-statement/)
- [open statement](https://d3codex.com/pickbasic-flashbasic/open-statement/)
- [read statement](https://d3codex.com/pickbasic-flashbasic/read-statement/)
- [readv statement](https://d3codex.com/pickbasic-flashbasic/readv-statement/)
- [release statement](https://d3codex.com/pickbasic-flashbasic/release-statement/)
- [Reserved words](https://d3codex.com/pickbasic-flashbasic/reserved-words/)
- [clearselect statement](https://d3codex.com/pickbasic-flashbasic/clearselect-statement/)
- [write statement](https://d3codex.com/pickbasic-flashbasic/write-statement/)
- [writev statement](https://d3codex.com/pickbasic-flashbasic/writev-statement/)
- [writevu statement](https://d3codex.com/pickbasic-flashbasic/writevu-statement/)

---
Source: https://d3codex.com/pickbasic-flashbasic/default-file-variables/ - part of the D3Codex reference.
