# mat statement

The mat statement assigns data to each
element of a dimensioned array variable to a specific value in one
operation.

## Syntax

```
mat array.var = exp
mat array.var1 = mat array.var2
```

## Description

Array variables must be defined
in a dim, common, or file statement.

## Example(s)

Copies one array into another.
The number of elements in *array.var1* must be greater
than or equal to the number of elements in *array.var2*. It is possible to assign a two-dimensional array to a single-dimensional
array and conversely.

```
Dim array(5)
qty = 10
mat array = qty

dim one(4,1)
mat one = 1
dim two(2,2)
mat two = mat one
```
Note: When assigning one matrix to another, the array to
the right of the equal sign must have the same total number of elements
as the matrix to the left of the equal sign.

This sets every
array element of `customer.item` to null.

```
mat customer.item = ""
```
This sets every array entry of `customer.item.history` to its corresponding entry in `customer.item`.

```
mat customer.item.history = mat customer.item
```
This example assigns all of the elements in the two dimensional
array, `a` into the one dimensional array, `b`. The rows are filled before the columns, therefore `a(2,1) = 2`.

```
dim a(10,2)
dim b(20)
mat b = 1
b(3) = 2
mat a = mat b
```

## See also

- [Assignment](https://d3codex.com/pickbasic-flashbasic/assignment/)
- [dimension statement](https://d3codex.com/pickbasic-flashbasic/dimension-statement/)
- [matbuild statement](https://d3codex.com/pickbasic-flashbasic/matbuild-statement/)
- [matparse statement](https://d3codex.com/pickbasic-flashbasic/matparse-statement/)
- [matread statement](https://d3codex.com/pickbasic-flashbasic/matread-statement/)
- [matreadu statement](https://d3codex.com/pickbasic-flashbasic/matreadu-statement/)
- [matwrite statement](https://d3codex.com/pickbasic-flashbasic/matwrite-statement/)
- [matwriteu statement](https://d3codex.com/pickbasic-flashbasic/matwriteu-statement/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)

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