Communications

mvBASIC includes several statements designed for communication programs on the mvBase system. Data can be sent to or taken from any remote line.

Unlinking and Attaching a Line

Before a program can communicate with a remote line, the line should first be attached with the LINE-ATT command. The LINE-ATT command can be executed only if the line is not already linked to another process. To unlink a line from a process, use the UNLINK-LINE command.

Sending Data to a Line (SEND, SENDX, SENDBREAK)

The SEND statement sends data to a remote line. SEND does not require that the remote line be attached, but it does require that the line not be linked to another process. The syntax of the SEND statement is based on that of the PRINT, CRT, and DISPLAY statements, in that it accepts commas for tabulation, @-functions for screen formatting, and even trailing colons for carriage return and linefeed suppression.

A variation of the SEND statement is the SENDX statement, which sends data written in ASCII hexadecimal format to the remote line, translating it into standard ASCII characters. The SENDX statement was designed for sending a segment mark (CHAR(255)), which is normally taken as the end-of-data character. If the SENDX statement is used, a segment mark can be converted to hexadecimal (FF) and thus be successfully transmitted. To convert data into ASCII hexadecimal, use the OCONV function with the MX conversion code.

Sending a BREAK

The SENDBREAK statement sends a break signal to the designated remote line. It might be used, for example, for hanging up modems that recognize a break as a hanging signal.

Receiving Data from a Line

There are several ways of receiving data from an attached line in mvBASIC. The INPUT and INPUTIF statements include FROM clauses, which can be used to specify a remote line from which the input should be taken. In addition, the GET and GETX statements are designed specifically for taking characters from a remote line.

The Type-ahead Buffer

The behavior of input statements often depends on the status of the type-ahead feature. The type-ahead feature is generally enabled on mvBase. When type-ahead is enabled, characters are accepted from a line even when there is no prompt for input. These characters are placed in the type-ahead buffer. The type-ahead buffer accepts up to 127 characters on input. The LIST-LINE-CHARS command displays, among other things, whether the type-ahead feature is currently on for each process, and how many characters are currently in the type-ahead buffer for that line.

If type-ahead is enabled, the characters in the type-ahead buffer are taken as responses to the next input request. Thus an operator who is familiar with a program can type responses to prompts before they are printed, without having to wait for the program to catch up.

The type-ahead feature is turned on by the TA-ON command and turned off with TA-OFF. A user logged on to the SYSPROG account can turn type-ahead on or off for any process, defaulting to the current process. In addition, the TA-ON and TA-OFF statements in mvBASIC can be used to toggle the type-ahead feature for the current process or for all attached processes. A programmer might wish to turn type-ahead off during execution if there is danger of a user making mistakes by responding too quickly. If a programmer chooses to turn off the type-ahead feature in a program, however, it should be turned on again before the program is terminated.

An alternative to turning type-ahead off is to clear the type-ahead buffer periodically. The type-ahead buffer can be cleared in mvBASIC with the TA-CLEAR or INPUTCLEAR statement. However, only the type-ahead buffer for the current line is cleared. To clear the type-ahead buffer for another line, the SYSPROG command PROTOCOL with the C option should be used.

To determine the number of characters currently in the type-ahead buffer for the current process, or for any other process, use the TA function.

See the TCL Reference Guide for more information on the type-ahead feature.

Input from an Attached Line (GET, GETX)

In general there are two ways to accept input from a remote attached line: through the FROM clauses of the INPUT and INPUTIF statements, or through the GET or GETX statement.

The GET statement is an all-purpose statement for taking input from an attached line. The GET statement will accept any character from the attached line, with the exception of segment marks (CHAR(255)), which are interpreted as the end of data. The GET statement includes many optional clauses, which determine the conditions at which the input is terminated, and whether the program should wait for input or just check the type-ahead buffer.

Among the conditions for termination supported by the GET statement are:

In addition to GET, mvBASIC supports a GETX statement, which is identical to GET except that the input characters from the remote line are translated into ASCII hexadecimal format before they are taken. The characters can then be converted back into normal ASCII characters with the ICONV function and the MX conversion code. The GETX statement was designed to accept segment marks from the remote line, which are normally interpreted as the end of data.

See Also

Overview of mvBASIC Statements and Functions

Assignment Statements

Intrinsic Functions

Internal Program Control

External Program Control

Sending Output to the Screen and Printer

Terminal Input

Dynamic Array Processing

Generalized String Processing

Dimensioned Arrays

Reading and Updating File Items

Reading and Writing Tapes or Floppy Disks

Execution Locks

Compiler Directives

Miscellaneous Statements and Functions

The Error Message Processor