# .chain command (Runoff)

The .chain command transfers control
to the specified item-ID.

## Syntax

```
.chain {file.reference} item-ID
```

## Parameter(s)

| file.reference | Specifies the file where the item change resides. If not specified, the current file is used. Control does not return to the source item. |
| --- | --- |
| item-ID | Specifies the item to transfer control to. |

## Example(s)

```
.chain next.doc
```
The item `next.doc` is processed at the
end of the document that called it.

## Description

This command is particularly
useful for generating form letters. For example, it may be necessary
to insert the name and address of each recipient of the letter from
a separate file.

A sselect statement is used
to extract the relevant data from the file and save it in a list.
A series of .readnext statements inserts the data
into the text of the letter. At the end of the letter, a .chain command may be used to restart the next letter.
When the list is exhausted, Runoff stops.

## See also

- [.read command (Runoff)](https://d3codex.com/runoff/dot-read-command-runoff/)
- [.readnext command (Runoff)](https://d3codex.com/runoff/dot-readnext-command-runoff/)
- [Runoff commands](https://d3codex.com/runoff/runoff-commands/)

---
Source: https://d3codex.com/runoff/dot-chain-command-runoff/ - part of the D3Codex reference.
