# readt statement

The readt statement reads a tape record and assigns the value
 returned to a specified variable.

## Syntax

```
readt var[then|else|onerr statement.block]
```

## Description

The length of the tape record is specified by the most recently executed TCL
 t-att command.

 The then clause is taken if the operation is successful.

 Either else or onerr can be specified, but not both. If
 the tape unit has not been attached or if an end-of-file (eof) mark is read, the
 else or onerr clause, if present, is executed. In
 addition, the onerr clause can be used to check for end-of-tape (eot), tape
 unit not ready, parity error, or block transfer error.

 Note: If a readt is attempted without a device attached, FlashBASIC or BASIC
 takes the else clause with system(0)
 `= 1`, but FlashBASIC or BASIC attempts the read.

## Example(s)

The example below reads a series of tape records and displays the first 25 bytes of each
 record. The readt
 else clause is usually taken when an end-of-tape or end-of-data condition is
 reached. The system(0) function indicates whether there are any other
 unexpected problems.

```
execute ’t-att’
rewind else stop
eot=0
loop
readt rec else eot=1
until eot do
print trim(rec[1,25])
repeat
```

## See also

- [list-device command](https://d3codex.com/tcl/list-device-command/)
- [onerr clause](https://d3codex.com/pickbasic-flashbasic/onerr-clause/)
- [readtx statement](https://d3codex.com/pickbasic-flashbasic/readtx-statement/)
- [rewind statement](https://d3codex.com/pickbasic-flashbasic/rewind-statement/)
- [set-sct command](https://d3codex.com/tcl/set-sct-command/)
- [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/)
- [t-att command](https://d3codex.com/tcl/t-att-command/)
- [t-select command](https://d3codex.com/tcl/t-select-command/)
- [then clause](https://d3codex.com/pickbasic-flashbasic/then-clause/)
- [then/else statement blocks](https://d3codex.com/pickbasic-flashbasic/then-else-statement-blocks/)
- [weof statement](https://d3codex.com/pickbasic-flashbasic/weof-statement/)
- [writet statement](https://d3codex.com/pickbasic-flashbasic/writet-statement/)

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