READT Statement

Reads the next record from a tape unit.

Syntax

READT variable [THEN statement(s) | ELSE statement(s)]

Syntax Elements

variable is the name of the variable to which the next record is assigned.

statement(s) is either a THEN or an ELSE clause (or both). A statement must be included. The THEN clause is executed if the read is successful. The ELSE clause is executed if the tape unit has not been attached, or if an end-of-file mark (EOF) is read.

Operation

DataBasic attempts to read a label (if present) on the first READT command, on the first READT after a rewind or after sensing an EOF. If you want to read unlabelled tapes you must first assign the tape using the LABEL=0 in the ASSIGN or T-ATT command.

The record size in the tape label determines the largest record that can be read. The minimum readable record size is 20 bytes.

If you have not attached the tape, your program is terminated and the system displays the error message:

[1129] NO SUCH TAPE ASSIGNMENT EXISTS

For more information on tape handling, refer to Tape Operation and Commands.

Examples

READT X ELSE PRINT "CANNOT READ"; STOP

Reads the next tape record and assigns it to X. If an EOF is detected or the tape is not attached, CANNOT READ is printed and the program terminates.

READT B ELSE
  PRINT "NO GOOD"
  GOTO 5
END

Reads next tape record and assigns its value to B.  If it cannot be read, the message NO GOOD is printed and control transfers to statement 5.