WRITET statement
Syntax
WRITET [UNIT (mtu)] variable{THEN statements [ELSE statements] | ELSE statements}
Description
Use the WRITET statement to write a tape record on a magnetic tape. The value of variable becomes the next tape record. variable is an expression that evaluates to the text to be written to tape.
The UNIT clause specifies the number of the tape drive unit. Tape unit 0 is used if no unit is specified. If the UNIT clause is used, mtu is an expression that evaluates to a code made up of three decimal digits, as shown in the following table:
| Code | Available Options |
|---|---|
| m (mode) | 0 = No conversion 1 = EBCDIC conversion 2 = Invert high bit 3 = Invert high bit and EBCDIC conversion |
| t (tracks) | 0 = 9 tracks. Only 9-track tapes are supported. |
| u (unit number) | 0 through 7 |
The mtu expression is read from right to left. If mtu evaluates to a one-digit code, it represents the tape unit number. If mtu evaluates to a two-digit code, the rightmost digit represents the unit number and the digit to its left is the track number.
If either mtu or variable evaluates to the null value, the WRITET statement fails and the program terminates with a run-time error message.
Each tape record is written completely before the next record is written. The program waits for the completion of data transfer to the tape before continuing.
Before a WRITET statement is executed, a tape drive unit must be attached (assigned) to the user. Use the ASSIGN command to assign a tape unit to a user. If no tape drive unit is attached or if the unit specification is incorrect, the ELSE statements are executed.
The largest record that the WRITET statement can write is system-dependent. If the actual record is larger, bytes beyond the system byte limit are not written.
The STATUS function returns 1 if READT takes the ELSE clause, otherwise it returns 0.
If NLS is enabled, WRITET and other BASIC statements that perform I/O operations always map external data to the internal character set using the appropriate map for the file. The map defines the external character set for the file that is used to input data on a keyboard, display data on a screen, and so on.
PIOPEN Flavor
If you have a program that specifies the syntax UNIT ndmtu, the nd elements are ignored by the compiler and no errors are reported.
Examples
The following example writes a record to tape drive 0:
RECORD=1S2S3S4
WRITET RECORD ELSE PRINT "COULD NOT WRITE TO TAPE"
The next example writes the numeric constant 50 to tape drive 2, a 9-track tape with no conversion:
WRITET UNIT(002) "50" ELSE PRINT "COULD NOT WRITE"