• Aucun résultat trouvé

300 !RECEIVE DATA MESSAGE IF ANY

Dans le document RSTS/E Programming Manual (Page 64-67)

If data is not available at the terminal, a message is pending. If data is available, the program can process it.

4.2 MULTIPLE TERMINAL SERVICE ON ONE I/O C~EL - RECORD 32767%+1%

The multiple terminal feature allows one program to interact with several terminals rather than merely having each terminal open for input or output. This feature is useful in applications such as order entry, inventory control, and query-response where the same function is performed on several terminals but a separate job for ~ach terminal is undesirable or inefficient.

10 OPEN "KB:- AS FILE NZ

or

10 OPEN -KB4:· AS FILE NZ

The first form associates channel N% with the job console keyboard and defines it as the master terminal. The sec-ond form associates channel N% with keyboard number 4 and defines it as the master terminal.

The program exercises control of additional, or slave, terminals, through special forms of the Record I/O GET and PUT statements. The terminals must be reserved to the job but must not be opened by the program. The user can establish the terminals as slave terminals with the ASSIGN immediate mode command before he runs the program.

Alternatively, the program can assign these terminals by executing the number 10 SYS system function call to FIP. The program can control any number of these additional terminals up to the maximum number of terminals on the system.

To perform input and output operations, the program uses GET (or INPUT) and PUT (or PRINT and PRINT USING) statements in a special manner. The RECORD option specifies a particular action and keyboard number.

4.2.1 Multiple Tenninal Service Output

A PUT statement of the following form performs output to a keyboard, either master or slave.

10 PUT +1%, RECORD 32767%t1ZtK%, COUNT NZ

The variable K% in the RECORD option is the unit number of the keyboard to which output is directed. As a re-sult, the number of characters specified by N% in the COUNT option is transferred from the buffer on channell to the designated keyboard. The only special error which can occur is NOT A VALID DEVICE (ERR

=

6), indi-cating that the terminal addressed is neither the master keyboard nor a slave keyboard reserved to the program.

Other possible errors such as I/O CHANNEL NOT OPEN (ERR

=

9) work in the standard fashion.

The RECORD option can be used with the PRINT or PRINT USING statement as well as 'with the PUT statement.

For example, the statements

20 PRINT 11%, RECORD 32767%t1ZtK%, Z$;

or

20 PRINT 11%, RECORD 32767%t1%tK%, USING "!" ,", Z$;

are valid to output the string Z$ to the unit designated by K%. With the PRINT or PRINT USING statement, the FIELD, LSET. and RSET statements associated with the PUT statement are unnecessary for moving data to an out-put buffer. By using PRINT or PRINT USING in place of PUT, the programmer eliminates some of the data moving code and can format the data more conveniently.

When the value 4096% is also included in the RECORD option, binary data can be output using this multiple ter-minal service. For example,

100 PUT IN%, RECORD 32767Zt1%t4096%+KZ, COUNT M%

is used to output the number of bytes of binary data specified by M% to the keyboard whose unit number is the variable K%.

4-2

4.2.2 Multiple Terminal Service Input

A GET statement of the following form performs input from a keyboard, either master or slave.

10 GET 11%, RECORD 32767%tl%tK%

The variable K% in the RECORD option is the unit designator (keyboard number) of the terminal from which in-put is requested. The GET statement transfers the data from the terminal inin-put buffer to the buffer for the des-ignated channel. The first character in the buffer contains the number of the keyboard from which the input came.

The total number of characters transferred, including the keyboard number, is given by the RECOUNT variable.

The program accesses the data by use of the standard FIELD statement. Since the first character of the I/O buffer is the keyboard number, the length of the data input is given by RECOUNT -1 %. If no input is available from the designated terminal, the USER DATA ERROR ON DEVICE error (ERR = 13) results. Because this error is recover-able, the program can execute an appropriate ON ERROR GOTO routine. The system does not allow a stall on in-put from a specific keyboard in multiple terminal arrangements.

The following form of the GET statement requests input from anyone of the multiple terminals.

10 GET 11%, RECORD 32767%+1%+16384%+8%

If input is pending from any terminal, the contents of that terminal's buffer are transferred to the buffer for the designated channel. The first character in the buffer is the keyboard number of the terminal from which input came. As described above for input from a specific keyboard, the FIELD statement can access the sending keyboard number and the data sent. The variable S% can have the values shown in Table 4-1. If no input is pending from any terminal, the program stalls as described for the case of S%=O% in Table 4-1.

Table 4-1 Multiple Terminal RECORD Values for S%

Value Meaning

S%=O% GET statement waits until input is available from anyone of the terminals. The system waits indefinitely if no input is pending. When input is available, the sys-tem transfers the data and the program accesses the data as described above. A USER DATA ERROR ON DEVICE error (ERR = 13) may occur due to a race condition with CTRL/C. No data is lost; simply re-issuing the GET statement continues operation.

1 %<So/0<255% GET statement waits up to S% seconds for input from any terminal. If no input is available from any terminal in S% seconds, the USER DATA ERROR ON DEVICE error (ERR = 13) occurs.

S%=8192% If no input is pending from any of the terminals, the USER DATA ERROR ON DEVICE error (ERR = 13) occurs immediately (see Section 4.1).

A CTRL/C combination typed at anyone of the slave terminals passes a CHR$(3) character to the program but does not terminate the program. The RECOUNT variable contains the value 2% representing the keyboard number and the CTRL/C character. The program can process the CTRL/C character as a special character. If CTRL/C is typed at the master terminal, the system terminates the program in the standard fashion.

4.3 TERMINAL CONTROL VIA THE MODE OPTION

Control of a terminal can be established in several ways by the MODE option in the OPEN statement. Table 4-2 summarizes the values allowed in the MODE option for a keyboard device.

Table 4-2 Summary of MODE Values for Terminals Mode

Value Effect

1% Binary input from a terminal 2% Reserved for future implementation

4% Suppress automatic carriage return/line feed at right hand margin

8% Enable echo control for block mode simulation (turns off other modes and automatically enables MODE 4%)

The following sections describe the various MODE options.

4.3.1 Binary Data Output and Input

To perform binary data output to a terminal, either opened on its own I/O channel or opened as one of many ter-minals on one I/O channel, execute a statement of the following form:

Dans le document RSTS/E Programming Manual (Page 64-67)