# matwrite statement

The matwrite statement writes an item
into the specified file.var.

## Syntax

```
matwrite array.var on {file.var,} ID.exp
```

## Description

This statement can optionally
be written matwrite or write. If mat is omitted, a matrix write can be determined
by the definition of the variable, *array.var*.
If no dim statement appears, it is automatically
treated as a dynamic array.

If *file.var* is
omitted, the default file variable is used.

The array is truncated
to the last nonnull array element. All trailing null elements are
deleted. If the array is defined by a file statement,
the file variable is not used.

The write, matwrite, and matwriteu statements all
wait until the actual disk update takes place before continuing execution
of the program. They are used for critical write-through, such as
error-logging.

## Example(s)

```
dim customer.item(30)
matread customer.item from customer.file,item-ID else...
customer.item(1)=newname
customer.item(30)=date()
matwrite customer.item on customer.file,item-ID
```

## See also

- [Array references](https://d3codex.com/pickbasic-flashbasic/array-references/)
- [Array variable](https://d3codex.com/pickbasic-flashbasic/array-variable/)
- [begin work statement](https://d3codex.com/pickbasic-flashbasic/begin-work-statement/)
- [callx (write trigger) processing code](https://d3codex.com/processingcodes/callx-write-trigger-processing-code/)
- [Default File Variables](https://d3codex.com/pickbasic-flashbasic/default-file-variables/)
- [delete() function](https://d3codex.com/pickbasic-flashbasic/delete-function/)
- [dimension statement](https://d3codex.com/pickbasic-flashbasic/dimension-statement/)
- [extract() function](https://d3codex.com/pickbasic-flashbasic/extract-function/)
- [File variable](https://d3codex.com/pickbasic-flashbasic/file-variable/)
- [ID expression](https://d3codex.com/pickbasic-flashbasic/id-expression/)
- [inputerr statement](https://d3codex.com/pickbasic-flashbasic/inputerr-statement/)
- [mat statement](https://d3codex.com/pickbasic-flashbasic/mat-statement/)
- [matbuild statement](https://d3codex.com/pickbasic-flashbasic/matbuild-statement/)
- [matparse statement](https://d3codex.com/pickbasic-flashbasic/matparse-statement/)
- [matread statement](https://d3codex.com/pickbasic-flashbasic/matread-statement/)
- [matreadu statement](https://d3codex.com/pickbasic-flashbasic/matreadu-statement/)
- [matwrite statement](https://d3codex.com/pickbasic-flashbasic/matwrite-statement/)
- [matwriteu statement](https://d3codex.com/pickbasic-flashbasic/matwriteu-statement/)
- [read statement](https://d3codex.com/pickbasic-flashbasic/read-statement/)
- [release statement](https://d3codex.com/pickbasic-flashbasic/release-statement/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [write statement](https://d3codex.com/pickbasic-flashbasic/write-statement/)
- [writeu statement](https://d3codex.com/pickbasic-flashbasic/writeu-statement/)

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