COBOL Manual for TNS and TNS/R Programs
Data Fundamentals
HP COBOL Manual for TNS and TNS/R Programsā522555-006
4-10
Files
Open Mode
The open mode is a dynamic attribute of a file connector; it controls which file
operations are permitted. In HP COBOL the status of a file connector always includes
an open mode.
A file connector that is open in any mode can be closed by a CLOSE statement, which
dissociates the file connector from the physical file and sets the open mode state to
Closed or Locked (see CLOSE).
An internal file connector that is open in any mode can be implicitly closed by a
CANCEL statement (see CANCEL
).
Exclusion Mode
In HP COBOL, you specify a fileās exclusion mode when you open it (see OPEN).
Table 4-4. File Open Modes
Mode File Operations Allowed Statements Allowed
Locked None UNLOCKFILE
Closed Execution of OPEN statement to associate file connector with
its physical file
OPEN
Input Record retrieval operations READ
CLOSE
Output Record creation operations (deletes existing records upon
opening file)
WRITE
CLOSE
Extend Record creation operations (retains existing records upon
opening file)
WRITE
CLOSE
I-O Record retrieval, creation, deletion, and replacement
operations (as allowed by file organization and access
modes)
READ
WRITE
REWRITE
DELETE
*
CLOSE
* Relative or indexed file only
Table 4-5. Exclusion Modes
Mode Other Processes Can Read File Other Processes Can Write to File
Shared Yes Yes
Protected Yes No
Exclusive No No