# matread statement

The matread statement reads the specified
item from the optionally specified *file.var*, or
if not specified, the default *file.var*, and stores
one attribute per element in the dimensioned array.

## Syntax

```

 matread array.var from {file.var,} ID.exp {then|else statement.block}
```

## Description

Warning: Using a matread from a program that is called from
 dictionary item is not recommended.

 This statement can optionally be written matread or
 read. If mat is omitted, a matrix read can be determined
 by the definition of the variable, *array.var*. If no dim
 statement appears, it is automatically treated as a dynamic array.

- The else clause is taken when the item is not on file.

- The then condition is taken when the item is read successfully.

 If a binary item is read, system(0) is set to 10. The
 variable string consists of the hexadecimal FID in attribute 1 and the hexadecimal frame in
 attribute 2.

 If the array is defined by a file statement, the file variable is not
 used.

 Note:

- If the number of attributes read in the item is less than the dimensioned array size, the trailing array elements are assigned a null string value.

- If more attributes are present in the item read than elements in the previously dimensioned array, then the last array element contains the extra attributes, with each attribute delimited by an attribute mark. Everything functions properly while the last array element remains unreferenced.

## Example(s)

This example writes the dimensioned array `a` on the default file, using
 `a` as the item-ID. Although there are only five elements in the array, each
 corresponds to two attributes (separated by attribute marks). Thus, ten total attributes are
 written.

```

 open ’customer’ to cust.fv
 dim customer.rec(20)
 matread customer.rec from cust.fv,item-ID
 dim a(5)
 mat a = "xyz":@am:"abc"
 matwrite a on "a"
```

## See also

- [() reserved characters](https://d3codex.com/pickbasic-flashbasic/parenthesis-reserved-characters/)
- [> relational operator](https://d3codex.com/pickbasic-flashbasic/greater-than-relational-operator/)
- [Array references](https://d3codex.com/pickbasic-flashbasic/array-references/)
- [Array variable](https://d3codex.com/pickbasic-flashbasic/array-variable/)
- [Arrays](https://d3codex.com/pickbasic-flashbasic/arrays/)
- [begin work statement](https://d3codex.com/pickbasic-flashbasic/begin-work-statement/)
- [Default File Variables](https://d3codex.com/pickbasic-flashbasic/default-file-variables/)
- [delete() function](https://d3codex.com/pickbasic-flashbasic/delete-function/)
- [extract() function](https://d3codex.com/pickbasic-flashbasic/extract-function/)
- [clearfile statement](https://d3codex.com/pickbasic-flashbasic/clearfile-statement/)
- [dimension statement](https://d3codex.com/pickbasic-flashbasic/dimension-statement/)
- [File variable](https://d3codex.com/pickbasic-flashbasic/file-variable/)
- [ID expression](https://d3codex.com/pickbasic-flashbasic/id-expression/)
- [locked clause](https://d3codex.com/pickbasic-flashbasic/locked-clause/)
- [mat statement](https://d3codex.com/pickbasic-flashbasic/mat-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/)
- [open statement](https://d3codex.com/pickbasic-flashbasic/open-statement/)
- [readv statement](https://d3codex.com/pickbasic-flashbasic/readv-statement/)
- [release statement](https://d3codex.com/pickbasic-flashbasic/release-statement/)
- [ereplace() function](https://d3codex.com/pickbasic-flashbasic/ereplace-function/)
- [statement blocks](https://d3codex.com/pickbasic-flashbasic/statement-blocks/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [system() function](https://d3codex.com/pickbasic-flashbasic/system-function/)
- [then/else statement blocks](https://d3codex.com/pickbasic-flashbasic/then-else-statement-blocks/)
- [u001c user exit](https://d3codex.com/pickbasic-flashbasic/u001c-user-exit/)
- [unlock-group command](https://d3codex.com/tcl/unlock-group-command/)
- [unlock-item command](https://d3codex.com/tcl/unlock-item-command/)
- [write statement](https://d3codex.com/pickbasic-flashbasic/write-statement/)
- [writev statement](https://d3codex.com/pickbasic-flashbasic/writev-statement/)
- [writevu statement](https://d3codex.com/pickbasic-flashbasic/writevu-statement/)

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