TTYSET statement

Syntax

TTYSET dynamic.array [ON {file.variable | LPTR [n] | MTU [n] } ] 
{THEN statements [ELSE statements] | ELSE statements}

Description

Use the TTYSET statement to set the characteristics of a terminal, line printer channel, or tape unit. If only dynamic.array is specified, the terminal characteristics for your terminal are set based on the contents of dynamic.array. dynamic.array is a dynamic array of eleven fields, each of which has multiple values. A description of the expected contents of each value of dynamic.array is given in the TTYGET statement.

file.variable is a terminal opened for sequential processing with the OPENDEV or OPENSEQ statements. If file.variable is specified, the terminal characteristics for the specified terminal are set.

n specifies a logical print channel with LPTR or a tape unit with MTU. If n is specified, the characteristics for the print channel or tape unit are set. n is in the range of 0 through 225 for logical print channels; the default is 0. n is in the range of 0 through 7 for tape units; the default is 0. On Windows you cannot specify a tape unit.

If the terminal characteristics are set, the THEN statements are executed.

If the device does not exist or cannot be opened, or if no dynamic array is returned, the ELSE statements are executed; any THEN statements are ignored.

If dynamic.array, file.variable, or n evaluates to the null value, the TTYSET statement fails and the program terminates with a run-time error message.

To build dynamic.array, get the current values of the terminal line using the TTYGET statement, manipulate the values, and reset them with the TTYSET statement. The best way to access the information in the dynamic array is to include the BASIC code UNIVERSE.INCLUDE TTY. The syntax for including this file is:

$INCLUDE UNIVERSE.INCLUDE TTY

This file equates each value of variable from the TTYGET statement with a name, so that each value can be easily accessed in your program. To take advantage of this code you must call variable tty$. Once this code is included in your program, you can use the names to access the values of the dynamic array. The TTYGET Statement Values table lists the names equated to the values of the dynamic array and describes the values.

Timeout Handling

You can set the MODE.MIN and MODE.TIME values to define timeouts for read operations over a communications line. MODE.MIN specifies the minimum number of characters to be received. MODE.TIME specifies time in tenths of a second. The two values interact to provide four cases that can be used as follows.

Intercharacter Timer

When you set the values of both MODE.MIN and MODE.TIME to greater than 0, MODE.TIME specifies the maximum time interval allowed between successive characters received by the communication line in tenths of a second. Timing begins only after the first character is received.

Blocking Read

When you set the value of MODE.MIN to greater than 0 and MODE.TIME to 0, no time limit is set, so the read operation waits until the specified number of characters have been received (or a newline in the case of READSEQ) statement.

Read Timer

When you set the value of MODE.MIN to 0 and MODE.TIME to greater than 0, MODE.TIME specifies how long the read operation waits for a character to arrive before timing out. If no characters are received in the time specified, the READSEQ and READBLK statements use the ELSE clause if there is one. If you use the NOBUF statement to turn off buffering, the timer is reset after each character is received.

Nonblocking Read

When you set the values of both MODE.MIN and MODE.TIME to 0, data is read as it becomes available. The read operation returns immediately.

  • If any characters are received:
    • READBLK returns as many characters as specified in the blocksize argument, or all the characters received, whichever is fewer.
    • READSEQ returns characters up to the first newline, or all the characters received if no newline is received.
  • If no characters are received, READSEQ and READBLK use the ELSE clause if there is one.