Document revision date: 30 March 2001

## OpenVMS I/O User's Reference Manual

Previous | Contents | Index

#### 5.4.1.4 Read Verify Function

When using the read verify function, the terminal driver performs input validation based on character attributes. (Read verification bypasses the optionally specified termination mask (TRM$_TERM).) Validation is performed one character at a time as data is entered. Invalid characters are not echoed, and cause the read operation to complete. It is then up to the application program to handle the error appropriately.

The initial string describes the initial contents of the input field. This string may consist of data and marker characters. The clear character is displayed on the screen for each occurrence of the fill character in the initial string buffer.

The picture string is a string of bytes where each byte corresponds to one character of the field being entered. Each byte specifies a mask of legal character types for that character position. If the byte is left as zero, then that position is a marker character, and the character from the initial string is echoed for that position.

For left-justified fields, the prompt data is output to the terminal, followed by an optional number (TRM$_INIOFFSET) of initial string characters. Leading marker characters are always output following the prompt, leaving the cursor at the leftmost data position. As each character is entered, it is validated and then echoed, advancing the cursor position. Additional marker characters are skipped as they are encountered. If an input character fails the validation, the read operation is completed with the invalid character as the terminator.

For right-justified fields, the prompt is output and is followed by the initial string. (In general, TRM$_INIOFFSET is set to the length of TRM$_INISTRNG for right-justified fields.) The cursor position remains one position to the right of the initial string. For proper operation, right-justified fields cannot have mixed picture definitions. After each character is input, the entire prompt and input fields are output. Therefore, the prompt should include a cursor positioning escape sequence.

The definition of full field is different for left- and right-justified read operations. For left-justified fields, full field is detected when the character corresponding to the last nonmarker position in the picture string has been entered. For right-justified fields, full field is detected when a character other than the fill character is shifted into the leftmost, nonmarker position in the field.

If the modifier TRM$M_TM_AUTO_TAB is set in TRM$_MODIFIERS, then detection of a full field terminates the read operation. In the event of autotab termination, the terminator character in the IOSB is null. If the autotab option is not selected, then termination occurs when one more character is typed to a full field. Applications can detect this condition when the terminating character index is one character beyond the end of the field. The extra character is reported as the terminator. In a left-justified field, the IOSB index to the terminator is zero-based; in a right-justified field, this index is one-based.

If a read verify function is interrupted by an asynchronous write operation, the read verify is completed with status SS$_OPINCOMPL.

No line editing functions other than the delete character function are supported for read verify.

### 5.4.2 Write

Write operations display the contents of a user-specified buffer on the associated terminal. The operating system provides the following write I/O functions, which are listed with their function codes:

- IO$_WRITEVBLK---Write virtual block
- IO$_WRITELBLK---Write logical block
- IO$_WRITEPBLK---Write physical block

The write function codes can take the following device- or function-dependent arguments:

- P1---The starting virtual address of the buffer that is to be written to the terminal.
- P2---The number of bytes that are to be written to the terminal. (The system generation parameter, MAXBUF, and the terminal driver limit the maximum size of the buffer. The terminal driver will only function with buffer sizes less than 32718 bytes.)
- P4---Carriage control specifier except for write physical block operations. (Write function carriage control is described in Section 5.4.2.2.)

P3, P5, and P6 are not meaningful for terminal write operations.

In write virtual block and write logical block operations, the buffer (P1 and P2) is formatted for the selected terminal and includes the carriage control information specified by P4.

Unless TT$M_MECHFORM is specified, multiple line feeds are generated for form feeds. The number of line feeds generated depends on the current page position and the length of the page. By producing a carriage return after the last line feed, a form feed also moves the cursor to the left margin. Multiple spaces are generated for tabs if the characteristics of the selected terminal do not include TT$M_MECHTAB (this does not apply to write physical block operations). Tab stops occur every eight characters or positions.

CTDRIVER and Buffered Output

CTDRIVER, a component of the SET HOST facility, buffers output from remote terminals in order to package multiple output requests into a single network transfer. As a result, control is returned early to the user with a status of SS$_NORMAL when the output buffer has been filled and successfully queued.

Note that this output might not be displayed if the user enters an abort character or a Ctrl/O.

#### 5.4.2.1 Function Modifier Codes for Write QIO Functions

Five function modifiers can be specified with IO$_WRITEVBLK, IO$_WRITELBLK, and IO$_WRITEPBLK. Table 5-9 lists these function modifiers. All write function modifiers are supported for LAT devices.

Table 5-9 Write QIO Function Modifiers for the Terminal Driver
Code | Consequence
--- | ---
IO$M_BREAKTHRU | Allows breakthrough read regardless of the current active state.
IO$M_CANCTRLO | Turns off Ctrl/O (if it is in effect) before the write operation. Otherwise, the data cannot be displayed.
IO$M_ENABLMBX | Enables use of the mailbox associated with the terminal for notification that unsolicited data is available.
IO$M_NOFORMAT | Allows you to specify write functions without interpretation or format; in effect, the terminal line is in a temporary PASTHRU mode.
IO$M_REFRESH | If a read operation is interrupted by a write operation (by either a write breakthrough 1 or any other type of write), the terminal displays the current read data when the read function is restarted.

1Any interruption caused by the execution of the $BRDCST or the $BRKTHRU system service broadcasting messages to terminals is referred to as a "write breakthrough."

#### 5.4.2.2 Write Function Carriage Control

The P4 argument is a longword that specifies carriage control. Carriage control determines the next printing position on the terminal. P4 is ignored in a write physical block operation. Figure 5-5 shows the P4 longword format.

Figure 5-5 P4 Carriage Control Specifier

Only bytes 0, 2, and 3 in the longword are used. Byte 1 is ignored. If the low-order byte (byte 0) is not 0, the contents of the longword are interpreted as a Fortran carriage control specifier. Table 5-10 lists the possible byte 0 values (in hexadecimal) and their meanings.

Table 5-10 Write Function Carriage Control (FORTRAN: Byte 0 Not Equal to 0)
Byte 0 Value (hexadecimal) | ASCII Character | Meaning
--- | --- | ---
20 | (space) | Single-space carriage control (sequence: carriage-return/line-feed combination, print buffer contents, return 1).
30 | 0 | Double-space carriage control (sequence: carriage-return/line-feed combination, carriage-return/line-feed combination, print buffer contents, return 1).
31 | 1 | Page eject carriage control (sequence: form feed, print buffer contents, return).
2B | + | Overprint carriage control; allows double printing for emphasis or special effects (sequence: print buffer contents, return).
24 | $ | Prompt carriage control (sequence: carriage-return/line-feed combination, print buffer contents).
All other values |  | Same as ASCII space character: single-space carriage control.

1A carriage-return/line-feed combination is a carriage return followed by a line feed.

If the low-order byte (byte 0) is 0, bytes 2 and 3 of the P4 longword are interpreted as the prefix and postfix carriage control specifiers. The prefix (byte 2) specifies the carriage control before the buffer contents are printed. The postfix (byte 3) specifies the carriage control after the buffer contents are printed. The sequence is as follows:

1. Prefix carriage control
2. Print
3. Postfix carriage control

The prefix and postfix bytes, although interpreted separately, use the same encoding scheme. Table 5-11 shows this encoding scheme in hexadecimal.

With several exceptions, Figure 5-6 shows the prefix and postfix hexadecimal coding that produces the carriage control functions listed in Table 5-10. Prefix and postfix coding provides an alternative way to achieve these controls.

In the first example in Figure 5-6, the prefix/postfix hexadecimal coding for a single-space carriage control (carriage-return/line-feed combination, print buffer contents, return) is obtained by placing the value 1 in the second (prefix) byte and the sum of the bit 7 value (80) and the return value (D) in the third postfix byte.

     80  (bit 7 = 1)
    + D  (return)
    ----
     8D  (postfix = return)

Table 5-11 Write Function Carriage Control (P4 byte 0 = 0)
Prefix/Postfix Bytes (Hexadecimal)
Bit 7 |  | Bits 0--6 |  | Meaning
--- | --- | --- | --- | ---
0 |  | 0 |  | No carriage control is specified (NULL).
0 |  | 1--7F |  | Bits 0 through 6 are a count of carriage-return/line-feed combinations.
Bit 7 | Bit 6 | Bit 5 | Bits 0--4 | Meaning
1 | 0 | 0 | 0--1F | Output the single ASCII control character specified by the configuration of bits 0 through 4 (7-bit character set).
1 | 1 | 0 | 0--1F | Output the single ASCII control character specified by the configuration of bits 0 through 4, which are translated as ASCII characters 128 through 159 (8-bit character set; see Appendix C).
1 | 1 | 1 | 0--1F | Reserved.

### 5.4.3 Set Mode

Set mode operations affect the operation and characteristics of the associated terminal line. The operating system provides two types of set mode functions: set mode and set characteristics.

The set mode function affects the mode and temporary characteristics of the associated terminal line. Set mode is a logical I/O function and requires no privilege. (If you do not have LOG_IO or PHY_IO privilege, the terminal driver does not accept a set mode request to a terminal that does not have the extended terminal characteristic TT2$M_SETSPEED---even if no request for a change of speed is made. Privilege is not required if TT2$M_SETSPEED is set but no attempt to change the speed is made.) The following function code is provided:

> IO$_SETMODE

The set characteristics function affects the permanent characteristics of the associated terminal line. Set characteristics is a physical I/O function and requires the privilege necessary to perform physical I/O. The following function code is provided:

> IO$_SETCHAR

Figure 5-6 Write Function Carriage Control (Prefix and Postfix Coding)

The set mode and set characteristics functions take the following device- or function-dependent arguments if no function modifiers are specified:

- P1---Address of characteristics buffer
- P2---Length of characteristics buffer (default length is 8 bytes)
- P3---Speed specifier (bits 0 through 7 = transmit; 8 through 15 = receive)
- P4---Fill specifier (bits 0 through 7 = CR fill count; bits 8 through 15 = LF fill count)
- P5---Parity flags

The P1 argument points to a variable-length block, as shown in Figure 5-7. With the exception of terminal characteristics, the contents of the block are the same for both the set mode and set characteristics functions.

Figure 5-7 Set Mode and Set Characteristics Buffers

In the buffer, the device class is DC$_TERM, which is defined by the $DCDEF macro. The terminal type is defined by the $TTDEF macro; for example, TT$_LA36. The page width is a value in the range of 1 through 511. The page length is a value in the range of 0 through 255. Table 5-5 lists the values for terminal characteristics. Table 5-6 lists the extended terminal characteristics. Characteristics values are defined by the $TTDEF and $TT2DEF macros.

Note Make sure that the selected device is a terminal before performing any set mode function, particularly when using SYS$INPUT or SYS$OUTPUT.

The P3 argument defines the device speed, such as TT$C_BAUD_300. The low eight bits specify the transmit speed, and the high eight bits specify the receive speed. If no receive speed is specified, the indicated transmit speed is used for both transmitting and receiving. If neither the transmit nor the receive speed is specified (P3 = 0), the baud rate is not changed. The terminal driver ignores the receive speed bits for interfaces that do not support split-speed operation. While speeds up to 19.2 K baud can be specified, not all controllers support all speed combinations. Refer to the associated hardware documentation to determine which speeds are supported by your controller.

P4 contains fill counts for the carriage-return and line-feed characters. Bits 0 through 7 specify the number of fill characters used after a carriage return. Bits 8 through 15 specify the number of fill characters used after a line feed.

P4 is applicable only if TT$M_CRFILL or TT$M_LFFILL is specified as a terminal characteristic for the current QIO request; see Table 5-5.

Several parity flags can be specified in the P5 argument:

- TT$M_ALTRPAR---Alter parity. If set, check the state of TT$M_PARITY and TT$M_ODD and, if indicated, change the parity. Otherwise, ignore these bits.
- TT$M_PARITY---Enable parity on terminal line if set, disable if clear.
- TT$M_ODD---Parity is odd if set.
- TT$M_ALTDISPAR---Alter dismiss parity errors. If set, check the state of TT$M_DISPARERR.
- TT$M_DISPARERR---Dismiss parity errors. If this mode is set, a character with a parity error is passed to the reader. An error message is not reported.

  Note If parity is enabled, the DZ11 generates a parity check bit to detect parity mismatch. Unless TT$M_DISPARERR is enabled, parity errors that occur during an I/O read operation are fatal to the operation. Parity errors that occur on input characters (that is, keys pressed on the keyboard) when no I/O operation is in progress might result in a character loss.

- TT$M_BREAK---Generate a break if set. The break is in effect until this bit is turned off. TT$M_BREAK is supported by the LTDRIVER for terminal servers that support the break capability, such as the DECserver 200 and DECserver 500. However, in the case of LAT terminals, the terminal server controls the duration of the break.
- TT$M_ALTFRAME---If set, the four low-order bits of P5 become the frame size. Note that the frame size is for data bits only and is exclusive of parity. TT$M_ALTFRAME is supported for frame sizes of 7 and 8 for LAT devices.

To take the existing parity settings, modify them, and use them in the set mode or set characteristic function, move the byte starting at the second nibble of the buffer that is going to be used in the P5 argument. For example, the following instructions change the parity from even to odd:

    insv    iosb+6, #4, #8, flags
    bisl    #tt$m_altrpar!tt$m_odd!tt$m_parity, flags

The following instruction then resets the parity to its original state:

    bicl    #tt$m_odd!tt$m_parity, flags

See Section 5.2.5 for information about the SET TERMINAL/FRAME command.

Application programs that change terminal characteristics should perform the following steps:

1. Use the IO$_SENSEMODE function to read the current characteristics.
2. Modify the characteristics.
3. Use the set mode function to write back the results.
4. If the characteristic is intended to be reset when the image exits, the application must perform this operation.

Failure to follow this sequence will result in clearing any previously set characteristic.

Two stop bits are used only for data rates less than or equal to 150 baud; higher data rates default to one stop bit.

The set mode and set characteristics functions can take the enable Ctrl/C AST, enable Ctrl/Y AST, enable out-of-band AST, hangup, set modem, broadcast, and loopback function modifiers that are described in the following sections.

Note If an attempt is made to turn on TT2$V_FALLBACK for a disconnected virtual terminal (_VTAx:) or if the Terminal Fallback facility has not been activated, the status code SS$_BADPARAM will be returned. For more information on TFF, refer to the OpenVMS Terminal Fallback Utility Manual (available on the Documentation CD-ROM).

#### 5.4.3.1 Hangup Function Modifier

The hangup function disconnects a terminal that is on a dialup line. (Dialup lines are described in Section 5.2.3.) The following combinations of function code and modifier are provided:

- IO$_SETMODE!IO$M_HANGUP
- IO$_SETCHAR!IO$M_HANGUP

The hangup function modifier takes no arguments. SS$_NORMAL is returned in the I/O status block.

Note For remote terminals, the hangup function breaks the network connection to the local system, ending the remote terminal session.

#### 5.4.3.2 Enable Ctrl/C AST and Enable Ctrl/Y AST Function Modifiers

Both set mode functions can take the enable Ctrl/C AST and enable Ctrl/Y AST function modifiers. These function modifiers request the terminal driver to queue an AST for the requesting process when you press Ctrl/C or Ctrl/Y. The following combinations of function code and modifier are provided:

- IO$_SETMODE!IO$M_CTRLCAST---Enable Ctrl/C AST
- IO$_SETMODE!IO$M_CTRLYAST---Enable Ctrl/Y AST

These function code modifier pairs take the following device- or function-dependent arguments:

> P1---Address of the AST service or 0 if the corresponding AST is disabled
> P2---AST parameter
> P3---Access mode to deliver AST (maximized with caller's access mode)

If the respective enabling is in effect, pressing Ctrl/C or Ctrl/Y gains the attention of the enabling process (see Table 5-2).

Enable Ctrl/C and Ctrl/Y AST are one-time enabling function modifiers. After the AST occurs, it must be explicitly reenabled by one of the two function code combinations before an AST can occur again. This function code is also used to disable the AST. The function is subject to AST quotas.

You can have more than one Ctrl/C or Ctrl/Y enabled; pressing Ctrl/C, for example, results in the delivery of all Ctrl/C ASTs. ASTs are queued and delivered to the user process on a first-in/first-out basis for each access mode. However, ASTs are processed in the reverse order of the Ctrl/C AST or Ctrl/Y AST requests that have been issued to the terminal driver (on a last-in/first-out basis).

If no enable Ctrl/C AST is present, the holder of an enable Ctrl/Y AST receives an AST when Ctrl/C is pressed; carriage-return/line-feed combination, ^Y, and Return are echoed.

Figure 5-8 shows the relationship of Ctrl/C and Ctrl/Y with the out-of-band function. If Ctrl/C or Ctrl/Y is an enabled out-of-band character, any out-of-band ASTs specified for this character are delivered. If IO$M_INCLUDE function modifier is included in the out-of-band AST request for this character, an enabled Ctrl/C or Ctrl/Y AST is also delivered.

Figure 5-8 Relationship of Out-of-Band Function with Control Characters

Enable Ctrl/C AST requests are flushed by the Cancel I/O on the Channel ($CANCEL) system service. Enable Ctrl/Y AST requests are flushed by the Deassign I/O Channel ($DASSGN) system service.

Ctrl/Y is normally used to gain the attention of the command interpreter and to input special commands such as DEBUG, STOP, and CONTINUE. Programs that are run from a command interpreter should not enable Ctrl/Y. Because ASTs are delivered on a first-in/first-out basis, the command interpreter's AST routine gets control first, and might not allow the program's AST to be delivered at all. Programs that require the use of Ctrl/Y should use the LIB$DISABLE_CTRL RTL routine to disable DCL recognition of Ctrl/Y.

Section 5.2.1.2 describes other effects of Ctrl/C and Ctrl/Y.

Previous | Next | Contents | Index

| privacy and legal statement |
6136PRO_019.HTML