# extract() function

The extract() function retrieves a specific
attribute, value, or subvalue from a dimensioned or dynamic array.

## Syntax

```
extract(dyn.array.exp, ac.exp)
extract(dyn.array.exp, ac.exp, vc.exp)
extract(dyn.array.exp, ac.exp, vc.exp, sc.exp)
```

## Parameter(s)

| dyn.array.exp | Array from which the specified attribute, value, or subvalue is extracted. |
| --- | --- |
| ac.exp | Attribute to extract. |
| vc.exp | Value to extract. |
| sc.exp | Subvalue to extract. |

## Description

extract() makes a copy of an element in a dynamic array rather than physically
removing the element. The original syntax of the extract() function is equally as valid as the dynamic array reference method.

Alternate method, using dynamic array reference symbols:

```
dyn.array.var< ac.exp>
dyn.array.var< ac.exp, vc.exp>
dyn.array.var< ac.exp, vc.exp,...
... sc.exp>
```
Note: An extract of attribute 0 is undefined and should
be avoided.

## Example(s)

All of these examples retrieve
the entire first attribute from the dynamic array, customer.item.

```
print extract(customer.item,1,0,0)
print extract(customer.item,1)
print customer.item<1>
```
Both of these examples retrieve the second value from
the first attribute of the dynamic array, `customer.item`.

```
print extract(customer.item(1),1,2)
print customer.item(1)<1,2>
```
Both of these examples assign the variable `name` to the first value from the first attribute of the array `customer.item`.

```
name = extract(customer.item(1),1,1)
name = customer.item(1)<1,1>
```

## See also

- [Array references](https://d3codex.com/pickbasic-flashbasic/array-references/)
- [Array variable](https://d3codex.com/pickbasic-flashbasic/array-variable/)
- [Assignment](https://d3codex.com/pickbasic-flashbasic/assignment/)
- [Attribute count expression](https://d3codex.com/pickbasic-flashbasic/attribute-count-expression/)
- [del statement](https://d3codex.com/pickbasic-flashbasic/del-statement/)
- [BASIC functions](https://d3codex.com/pickbasic-flashbasic/basic-functions/)
- [insert() function](https://d3codex.com/pickbasic-flashbasic/insert-function/)
- [locate statement](https://d3codex.com/pickbasic-flashbasic/locate-statement/)
- [read statement](https://d3codex.com/pickbasic-flashbasic/read-statement/)
- [ereplace() function](https://d3codex.com/pickbasic-flashbasic/ereplace-function/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [Subvalue count expressions](https://d3codex.com/pickbasic-flashbasic/subvalue-count-expressions/)
- [Value count expression](https://d3codex.com/pickbasic-flashbasic/value-count-expression/)
- [write statement](https://d3codex.com/pickbasic-flashbasic/write-statement/)

---
Source: https://d3codex.com/pickbasic-flashbasic/extract-function/ - part of the D3Codex reference.
