# replace statement

The replace statement maintains referential
integrity between items that contain bidirectional bridges used by
the Update processor by eliminating duplicate item-IDs.

## Syntax

```
replace file.var, item-ID.old with item-ID.new
```

## Parameter(s)

| file.var | File that contains the duplicate item-IDs |
| --- | --- |
| item-ID.old | Item to be replaced with item-ID.new. |
| item-ID.new | Item to replace item-ID.old. |

## Description

*item-ID.new* replaces *item-ID.old* in bridged-to items. *item-ID.old* is deleted after replacement. In order for
the database to be consistent, there should be two-way bridges between
the references.

## Example(s)

Assume that two files exist with
the data shown below. Both files contain a bridge to attribute 1 of
the other file.

| File1 | File2 | | |
| --- | --- | --- | --- |
| ID | Attr1 | ID | Attr1 |
| b | 1 | 1 | b |
| c | 2 | 2 | c |
| d | 3 | 3 | d |
Now assume that this FlashBASIC or BASIC program is run:

```
open "file1" to f1
replace f1,"b" with "c"
```
Now, the files contain:

| File1 | File2 | | |
| --- | --- | --- | --- |
| ID | Attr1 | ID | Attr1 |
| c | 1]2 | 1 | c |
| d | 3 | 2 | c |
| | | 3 | d |

## See also

- [b (bridge) processing code](https://d3codex.com/processingcodes/b-bridge-processing-code/)
- [ereplace() function](https://d3codex.com/pickbasic-flashbasic/ereplace-function/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)

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