# b (bridge) processing code

The b processing code maintains a horizontal
relationship (bridge) between an attribute in one item and an item
in another file (or the same file) on the system level.

If you attempt to file or restore a bridge in an FSI file-defining
item, it will be commented-out with an asterisk (`*`).

This processing code is supported only from the VME.

| System Processors | Update |
| --- | --- |
| Code Type | File Defining |
| Dictionary Attributes | Correlative |

## Syntax

```
bfile.reference;attr1;attr2{;{attr3;+|-}|d}
```

## Parameter(s)

| file.reference | Refers to the file in which the bridge is being built. |
| --- | --- |
| attr1 | Contains the attribute in the current item that contains the item-ID of the item in the bridged-to file. This attribute can be multivalue in the current file. If it is multivalue, all items are updated in the bridged-to file. |
| attr2 | Contains the attribute in the bridged-to item that is referenced by the bridge. Unless the optional operator parameter is specified, this attribute contains the item-ID of the current item as a cross-reference to the current file. If the optional operator parameter is specified as an arithmetic operation with an operand attribute count 3, the attribute contains the result of the arithmetic operation. |
| attr3;+\|- | Adds or subtracts the value of the attribute specified by attribute count 3 in the current item to the value in the attribute count 2 in the bridged-to item. The inverse operation is performed on a delete. No backward pointer is maintained in the bridged-to item. If the current item is deleted, the inverse operation is performed to automatically return the value in attribute count 2 to its original value. |
| d | Used as an override to delete the current item even if attribute count 1 is not null. Without this option, the current item may not be deleted if the attribute specified by attribute count 1 contains a value. All values of attribute count 1 in the current item are processed. If a value in attribute count 1 is changed, the value of attribute count 2 in the original item specified by attribute count 1 is deleted, and this value is added to attribute count 2 of the new item pointed to by attribute count 1. |

## Description

The advantage of a bridge correlative is that it performs
a function that previously took significant FlashBASIC coding. When
an item is added, changed, or deleted, all the bridge correlatives
in the file-defining item of the file dictionary are processed for
that item.

Note: When using correlatives from the FSI during a
restore, illegal or unsupported correlatives are automatically commented
out (by inserting a leading asterisk (`*`)). For example,
any correlatives intended for use within the VME whose formats would
not work properly within the FSI are automatically commented out.

## Example(s)

**Example 1**

 The following example places the item-ID of the current item into attribute 5 of the entity
 file. Attribute 1 in the current file contains the item-ID in the entity file.

```
bentity;1;5
```

 **Example 2**

 The following example adds the value of attribute 3 in the current item to the value in
 attribute 4 of the bridged-to item (product file). The result of the addition is stored in
 attribute 4 of the bridged item.

```
bproduct;2;4;3;+
```

## mvBase B Correlative

The B correlative allows mvBASIC subroutines to process data from within an Attribute
 Definition item. Two forms of the B correlative are supported. If file name is specified when
 using either form of the B correlative, the file’s dictionary must contain the compiled object
 code for the specified subroutine. If file name is not specified, the specified subroutine must
 be cataloged.

 **Syntax (Form 1)**

```
B;[file.name] sub.name
```

 **Syntax (Form 2)**

```
B:[file.name] sub.name
```

 **Parameters**
| file.name | Specifies the file in which the subroutine resides. |
| --- | --- |
| sub.name | Specifies the name of the subroutine. |

 **Description**

 The first form passes data to the subroutine, and receives data from the subroutine a single
 value at a time. The B correlative can appear on line 7 or 8 of the Attribute Definition item.
 It can be included with A or F correlatives, and within a series of multiple conversion
 codes.

 The second form of the B correlative can be used when multiple values are to be processed as a
 set rather than a single value at a time. The entire attribute, including all multivalues and
 multi-subvalues, are passed to the specified subroutine. The subroutine can return a result with
 multivalues or multi-subvalues.

 When the second form of the B correlative is used, it must be specified on line 8 of the
 Attribute Definition item. The B correlative cannot be included with the A or F correlatives, or
 within a series of multiple conversion codes.

## Example(s)

This example creates an index for a report that is to be generated. The Attribute Definition
 item for REGION.INDEX and the subroutine shown below create an index file which may be sorted
 after the report has been
 generated.
```
0001 A
0002 12
0003
0004
0005
0006
0007
0008 B;BP INX
0009 L
0010 10
```

## See also

- [File reference (Access Query Language)](https://d3codex.com/access/file-reference-access-query-language/)
- [File-defining items](https://d3codex.com/definitions/file-defining-items/)
- [output-conversion](https://d3codex.com/attributedefiningitem/output-conversion/)
- [Processing codes overview](https://d3codex.com/processingcodes/processing-codes-overview/)
- [Processing codes](https://d3codex.com/processingcodes/processing-codes/)
- [replace statement](https://d3codex.com/pickbasic-flashbasic/replace-statement/)

---
Source: https://d3codex.com/processingcodes/b-bridge-processing-code/ - part of the D3Codex reference.
