Compaq AAQ2G1FTK Marine Radio User Manual


 
Processing Files and Records
6.2 Identifying Files and Records from Within Your Compaq COBOL Program
Example 610 (Cont.) Dening a Magnetic Tape File (Tru64 UNIX)
A000-BEGIN.
OPEN INPUT MYFILE-PRO.
.
.
.
READ MYFILE-PRO AT END DISPLAY "end".
.
.
.
CLOSE MYFILE-PRO.
For each OPEN verb referring to a file assigned to magnetic tape, the user is
prompted to assign the file to a magnetic tape device. These device names are
in the form
/dev/rmt0(a,l,m,h)
...
/dev/rmt31(a,l,m,h)
and correspond to
special files on the system that refer to mass storage tape devices. For more
information on tape devices see the
mtio(7)
Tru64 UNIX manual page.
As an alternative to prompting, each file assigned to a magnetic tape can have its
associated tape device defined through a shell environment variable. The name
of this environment variable is the concatenation of COBOL_TAPE_ and the base
of the file name used in the COBOL program. The value of this environment
variable is the name of the desired tape device. The environment variable needed
in Example 6–10 to assign the MARCH.311 file to tape device /dev/rmt0a is:
% setenv COBOL_TAPE_MARCH /dev/rmt0a
Establishing File Names with ASSIGN and VALUE OF ID
If the file specification is subject to change, you can use a partial file specification
in the ASSIGN clause and complete it by using the optional VALUE OF ID clause
of the FD entry. In the VALUE OF ID clause, you can specify a nonnumeric
literal or an alphanumeric WORKING-STORAGE item to supplement the file
specification.
VALUE OF ID can complete a file name specified in ASSIGN TO:
ASSIGN TO "filename"
VALUE OF ID ".ext"
In the above example, OPEN would create a file with the name ‘‘filename.ext’’.
VALUE OF ID can override a file name specified in ASSIGN TO:
ASSIGN TO "oldname"
VALUE OF "newname"
In the above example, OPEN would create a file with the name ‘‘newname’’.
VALUE OF ID can be a directory/device specification and ASSIGN TO can provide
the file name, as in the following example:
ASSIGN TO "filename.dat"
VALUE OF ID "/usr/"
or
ASSIGN TO "filename"
VALUE OF ID "DISK:[DIRECTORY]"
On OpenVMS, with this code OPEN would create a file with the name
DISK:[DIRECTORY]FILENAME.DAT.
Processing Files and Records 617