# writev statement

The writev statement writes the value
of an expression into the attribute designated in the attribute expression
parameter, using the item-ID specified in *ID.exp*.

## Syntax

```
writev exp ON {file.var,} ID.exp, ac.exp
```

## Parameter(s)

| exp | Expression to write to the specified file. |
| --- | --- |
| file.var | File to write to. Contains the item expressed in ID.exp. If omitted, the default file variable is used. |
| ID.exp | Item to write to. Contains the attribute expressed in ac.exp. |
| ac.exp | Attribute to write to. |

## Description

`–1` can be used
as the value of the attribute count expression. This appends a new
attribute to the end of the item.

writev requires
that the entire item be read into temporary workspace so that it can
be rebuilt with the new attribute value, before it is written back
to the file.

A series of writev statements
addressing different attributes in the same item can get very slow
because the item has to be reread for every writev.

A further problem with writev is that
it is not atomic. A writev, although faster, is
equivalent to this fragment of BASIC code:

```
xx<attr> = str
write xxon file, item
```

## Example(s)

```
writev time() on control.file,’control.list’,3
```

## See also

- [Attribute count expression](https://d3codex.com/pickbasic-flashbasic/attribute-count-expression/)
- [begin work statement](https://d3codex.com/pickbasic-flashbasic/begin-work-statement/)
- [Default File Variables](https://d3codex.com/pickbasic-flashbasic/default-file-variables/)
- [File variable](https://d3codex.com/pickbasic-flashbasic/file-variable/)
- [ID expression](https://d3codex.com/pickbasic-flashbasic/id-expression/)
- [matread statement](https://d3codex.com/pickbasic-flashbasic/matread-statement/)
- [readv statement](https://d3codex.com/pickbasic-flashbasic/readv-statement/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [writevu statement](https://d3codex.com/pickbasic-flashbasic/writevu-statement/)

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