COBOL Manual for TNS and TNS/R Programs

Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
28-16
EDIT Files
EDIT Files
An EDIT file is a special form of unstructured file whose file code is 101. HP COBOL
programs can read, write, and create EDIT files. The file code 101 must be assigned to
the file in one of these ways before the HP COBOL program opens the file:
Create the file outside the program (with an HP editor or FUP).
Have the HP COBOL program create the file by calling the FILE_CREATE_
procedure.
Before executing the HP COBOL program, use the TACL command ASSIGN to
associate the file’s name with the file code 101.
If the program runs in the CRE, have the program call the routine
COBOL_ASSIGN_ to associate the file’s name with the file code 101.
Creating and Using HP COBOL Relative Files
In a relative file—a file with relative organization—records are accessed by their record
numbers. A record number is the position, relative to the beginning of the file, at which
the record is stored. It is not related to the order in which the records were entered in
the file. Record numbers need not be consecutive; for example, you can create a
relative file with only three records whose numbers are 12, 19435, and 237.
An HP COBOL program can create and write a relative file that any other HP product
can later read. An HP COBOL program can read a relative file created by any HP
product.
An HP COBOL program can create, read, write, and purge relative files. An
HP COBOL program must use the FILE_CREATE_ procedure to create a relative file
that has alternate keys.
An HP COBOL program cannot create a relative file that has alternate keys directly,
because the operating environment maintains the alternate keys in one or more
separate files whose names are recorded with the operating environment information
about the relative file (see Alternate Record Keys).
An HP COBOL program can create a relative file that does not have alternate keys
simply by describing the file as having relative organization (but without alternate keys)
and opening the file for OUTPUT, EXTEND, or I-O. The HP COBOL run-time routines
create the relative file.
There is one important difference between the way HP COBOL uses relative files and
the way many other HP utilities use them: HP COBOL calls the first record in a relative
file record 1, and the operating environment and most other HP software call the first
record in a relative file record 0.