Kednos PL/I for OpenVMS Systems
User Manual


Previous Contents Index


Chapter 8
Input/Output Statement Options

PL/I permits the specification of the OPTIONS keyword on I/O statements and supports certain options for each statement. This chapter explains how to code options for I/O statements, lists the valid options for each I/O statement, and describes each option individually.

An I/O statement option remains in effect only for the duration of the statement on which it is specified. The only exception to this rule is the INDEX_NUMBER option.

8.1 Option Format

I/O statement options are specified in a statement by the OPTIONS keyword and an options list. You enclose the options list in parentheses, and separate individual options by commas, as follows:

OPTIONS (option,... ; 

Following is an example of the I/O statement GET with three options, PROMPT, NO_ECHO, and PURGE_TYPE_AHEAD:


GET LIST (PASSWORD) OPTIONS (PROMPT('Enter password: '), 
                             NO_ECHO, 
                             PURGE_TYPE_AHEAD); 
Any option that does not require an argument can be followed by a Boolean expression in the following format:

option(Boolean-expression) 

where Boolean-expression is a bit string of length 1,1B for true or 0B for false. If no Boolean expression is specified and the option is present in the option list, the default value of true is supplied.

8.2 Summary of Input/Output Statement Options

Table 8-1 lists the I/O options, briefly describes their uses, indicates which statements they are valid for, and gives their data types.

Table 8-1 Summary of Input/Output Statement Options
Option Usage Valid Statements Data Type
CANCEL_CONTROL_O Disables effect of Ctrl/o prior to terminal output. PUT BIT(1)
FAST_DELETE Deletes a record without updating alternate indexes. DELETE BIT(1)
FIXED_CONTROL_FROM (variable) Modifies the fixed control area of a record. REWRITE
WRITE
Data type of fixed control area
FIXED_CONTROL_TO (variable) Returns the contents of the fixed control area READ Data type of fixed control area
INDEX_NUMBER (expression) Specifies the index to which an I/O operation applies. DELETE
READ
REWRITE
FIXED BINARY(31)
LOCK_ON_READ Locks a record for reading and allows other readers but no writers. READ BIT(1)
LOCK_ON_WRITE Locks a record for writing and allows other readers but no writers. READ BIT(1)
MANUAL_UNLOCKING Specifies that the user, not RMS, is to control record locking and unlocking. READ BIT(1)
MATCH_GREATER Matches any key with a value greater than the value of the KEY option. DELETE
READ
REWRITE
BIT(1)
MATCH_GREATER_EQUAL Matches any key with a value greater than or equal to the value of the KEY option. DELETE
READ
REWRITE
BIT(1)
MATCH_NEXT Matches any key with a value greater than the value of the KEY option. DELETE
READ
REWRITE
BIT(1)
MATCH_NEXT_EQUAL Matches any key with a value greater than or equal to the value of the KEY option. DELETE
READ
REWRITE
BIT(1)
NO_ECHO Suppresses display of input data on a terminal. GET BIT(1)
NO_FILTER Suppresses recognition of Ctrl/u, Ctrl/r, and the DEL key on input operations. GET BIT(1)
NOLOCK Disables record locking for the current operation. READ BIT(1)
NONEXISTENT_RECORD Locks a nonexistent record. READ BIT(1)
PROMPT (expression) Writes a prompting message prior to an input operation. GET CHAR(*)
PURGE_TYPE_AHEAD Clears a terminal's type-ahead buffer before reading input data. GET BIT(1)
READ_REGARDLESS Enables a record to be read regardless of any lock. READ BIT(1)
RECORD_ID (variable) Accesses a record based on its internal identification. DELETE
READ
REWRITE
(2) FIXED BINARY(31)
RECORD_ID_TO (variable) Returns the value of a record's internal identification. READ
REWRITE
WRITE
(2) FIXED BINARY(31)
TIMEOUT_PERIOD (expression) Avoids a potential deadlock by indicating the number of seconds to wait before returning an error; used only with WAIT_FOR_RECORD. READ FIXED BINARY(31)
WAIT_FOR_RECORD If a record is locked, causes the process to wait until it is available. READ BIT(1)

8.2.1 CANCEL_CONTROL_O Option

The CANCEL_CONTROL_O option specifies, when the output device is a terminal, that the effect of Ctrl/o is disabled before data is output. This ensures that the beginning of the output list is displayed.

Rules

Usage

Use this option on a PUT statement that you want displayed regardless of whether previous output has been interrupted by Ctrl/o. By default, the Ctrl/o function remains in effect until another Ctrl/o. For example:


PUT SKIP LIST('Phase 1 complete... beginning phase 2...') 
          OPTIONS (CANCEL_CONTROL_O); 
If program output has been suspended by Ctrl/o prior to execution of the PUT statement, the CANCEL_CONTROL_O option on the PUT statement cancels the effect of the Ctrl/o and outputs the data list.

8.2.2 FAST_DELETE Option

The FAST_DELETE option specifies, for a record in an indexed sequential file with alternate indexes, that only the current index for the file is to be updated.

The alternate index or indexes for the deleted record are not updated until the next time access is attempted to the record through an alternate index.

Rules

Usage

This option can improve the speed of deletions when an indexed sequential file is updated.

8.2.3 FIXED_CONTROL_FROM Option

The FIXED_CONTROL_FROM option specifies a value to be written in the fixed control portion of a record in a file with variable-length records and a fixed control area. The format of the option is as follows:

FIXED_CONTROL_FROM (variable-reference) 

variable-reference

Specifies the variable associated with the fixed control area. The variable can be a scalar or a connected aggregate variable. It must not be an unaligned bit string or an aggregate consisting entirely of unaligned bit-string variables.

Rules

Usage

The following example illustrates writing a file with sequence numbers in a fixed control area:


DECLARE (OUTFILE,INFILE) FILE, 
        LINE_NUM FIXED BINARY(15), /* sequence numbers */ 
        COPY_REC CHARACTER(132) VARYING, 
        EOF BIT(1) STATIC INIT('0'B); 
OPEN FILE(INFILE) INPUT SEQUENTIAL; 
ON ENDFILE(INFILE) EOF = '1'B; 
OPEN FILE (OUTFILE) OUTPUT RECORD SEQUENTIAL 
         ENVIRONMENT (FIXED_CONTROL_SIZE(2)); 
READ FILE(INFILE) INTO(COPY_REC); 
/* Increment sequence number; copy record to output file */ 
DO LINE_NUM = 100 BY 100 WHILE (^EOF); 
       WRITE FILE(OUTFILE) FROM (COPY_REC) 
            OPTIONS(FIXED_CONTROL_FROM (LINE_NUM)); 
       READ FILE(INFILE) INTO(COPY_REC); 
       END; 
CLOSE FILE (INFILE); 
CLOSE FILE(OUTFILE) ENVIRONMENT (SPOOL); 
In this example, the OpenVMS file associated with the PL/I file OUTFILE will have a 2-byte fixed control area. Line numbers are assigned in increments of 100. Note that a file in this format, that is, a file that has CARRIAGE_RETURN_FORMAT carriage control (the default) and a 2-byte fixed control area, is handled in a special way by the OpenVMS system. When this file is printed with the DCL command PRINT or queued by the SPOOL option (as in this example), the contents of the fixed control area are printed to the left of each record on the output listing.

8.2.4 FIXED_CONTROL_TO Option

The FIXED_CONTROL_TO option specifies that the contents of the fixed control area of a record in a file with a fixed control area are to be assigned to a specified variable. The format of the option is as follows:

FIXED_CONTROL_TO (variable-reference) 

variable-reference

Specifies the variable associated with the fixed control area. The variable can be a scalar or a connected aggregate variable. It must not be an unaligned bit string or an aggregate consisting entirely of unaligned bit-string variables.

Rules

8.2.5 INDEX_NUMBER Option

The INDEX_NUMBER option specifies the particular index in an indexed sequential file to which a KEY option applies (primary index, secondary index, and so on). The format of this option is as follows:

INDEX_NUMBER (integer-expression) 

integer-expression

Specifies the index to be used. The value of the integer expression must be the number of an index for records in an indexed sequential file. The primary index is 0, the secondary index is 1, and so on.

Rules

Usage

The INDEX_NUMBER option on an I/O statement overrides the current index number, which can be set explicitly by the INDEX_NUMBER option of ENVIRONMENT or implicitly by a WRITE statement that specifies the KEY option or the RECORD_ID option.

When the INDEX_NUMBER option is used, the specified index becomes the current index for the file and is used in this and in all subsequent I/O operations until the INDEX_NUMBER option is again specified. For example:


GET LIST(BIRD) OPTIONS (PROMPT('Enter bird')); 
 
READ FILE(STATEFILE) INTO(STATE) KEY(BIRD) 
            OPTIONS (INDEX_NUMBER(2)); 

In this example, the READ statement accesses the record in the file STATEFILE using the index numbered 2.

8.2.6 LOCK_ON_READ Option

The LOCK_ON_READ option specifies a lock for reading that allows other readers but no writers. If you specify this option, then a record stream with a shared file that is open for reading only, is permitted to lock a record from modification by other programs or streams. Other streams are permitted to read the record but not to lock it.

Rules

8.2.7 LOCK_ON_WRITE Option

The LOCK_ON_WRITE option specifies that a record will be locked for possible modifications. However, readers will be able to access the record. Streams that are locking records for modification can therefore allow nonlocking streams to read locked records.

Rules

8.2.8 MANUAL_UNLOCKING Option

The MANUAL_UNLOCKING option specifies that a record will be locked until it is explicitly unlocked by the process, thus giving you (instead of RMS) control over locking and unlocking.

Rules

8.2.9 MATCH_NEXT Option

The MATCH_NEXT option specifies that the record of interest is the first record whose key is greater than the key specified in the KEY option. MATCH_NEXT overrides the default rule for key matching, which is to look for an exact key match.

MATCH_GREATER is an obsolete synonym for MATCH_NEXT.

Rules

Usage

In the following example, STATE_FILE's third alternate key (that is, index number 3) is a fixed binary population value:


DECLARE 1 STATE, 
          2 NAME CHARACTER(20),         /* Primary key */ 
          2 POPULATION FIXED BINARY(31),/* index #3 */ 
          2 CAPITAL, 
           .
           .
           .
        SIZE FIXED BINARY(31), 
        STATE_FILE FILE RECORD INPUT KEYED SEQUENTIAL; 
           .
           .
           .
GET LIST(SIZE) OPTIONS(PROMPT( 
       'Population value: ')); 
READ FILE(STATE_FILE) INTO(STATE) KEY(SIZE) 
       OPTIONS(MATCH_NEXT,INDEX_NUMBER(3)); 
This READ statement obtains the record for the state whose population is greater than the value entered for the GET statement. For example, a value can be entered in response to this prompt as follows:


Population value: 8000000
In this case, the READ statement would read the first record in the index numbered 3 whose key value is greater than 8000000.

8.2.10 MATCH_NEXT_EQUAL Option

The MATCH_NEXT_EQUAL option specifies that the record of interest is the record whose key matches the key specified in the KEY option or, if no match is found, the first record whose key is greater than the key specified.

MATCH_GREATER_EQUAL is an obsolete synonym for MATCH_NEXT_EQUAL.

Rules

8.2.11 NO_ECHO Option

The NO_ECHO option specifies, when the input device is a terminal, that the data entered at the terminal will not be displayed as it is entered.

Rules

Usage

This option is useful when data entered at a terminal is to be protected from being seen by users other than the one who entered the data. For example, if a password is to be entered, the NO_ECHO option protects the password, as follows:


GET LIST (PASSWORD) OPTIONS (NO_ECHO, 
                            PROMPT('Enter Password: ')); 
Data entered in response to this GET statement is not displayed on the terminal.

8.2.12 NO_FILTER Option

The NO_FILTER option specifies, when the input device is a terminal, that the recognition of Ctrl/u, Ctrl/r, and the DEL key is to be suppressed. These characters are interpreted as terminators.

Rules

Usage

When NO_FILTER is in effect, the terminal keys that normally permit a user to edit data as it is entered do not perform their normal functions. For example:


123[DEL]
If this data is entered in response to a GET statement that specifies the NO_FILTER option, the DEL key does not delete the last character typed (3); instead, it acts as the terminator of the input, just as the RETURN key usually does, and the value 123 is assigned to the input variable.

8.2.13 NOLOCK Option

The NOLOCK option specifies that a record accessed with a READ statement is not to be locked during the current operation.

Rules

Usage

The NOLOCK option can improve the speed of reading if it is used on a file that is opened with the ENVIRONMENT option SHARED_READ or with both SHARED_READ and SHARED_WRITE.


Previous Next Contents Index