FORTRAN Reference Manual

Introduction to File I/O in the HP NonStop
Environment
FORTRAN Reference Manual528615-001
5-20
Structured Files
The following example shows how to create the entry-sequenced file VISITORS. The
default record size for the file is 80 bytes.
Your FORTRAN program might include the following statement to connect the file to a
unit:
OPEN (13, FILE='visitors', ACCESS='SEQUENTIAL',
& STATUS='OLD', FORM='FORMATTED')
The following statement adds a record to the file:
WRITE (13, FMT=20) name, address, date
The following statements update a record in the file:
READ (13, FMT=30, REC=80, UPDATE=.TRUE.) name, address, date
address='145 N. Main'
WRITE (13, FMT=30, UPDATE=.TRUE.) name, address, date
Relative Files
A relative file stores records relative to the beginning of the file, according to a record
number supplied by the application program. In a relative file:
All physical records are the same length.
Logical records can vary in length.
Each record is uniquely identified by a record number, which denotes an ordinal
position in a file. You can access a record by record number or by alternate key.
(For more information about alternate key access, see Using Alternate Keys on
page 5-22.)
You can delete a record.
You can change the length of a record so long as the length does not exceed the
specified record size for the file.
A value of -2 for the REC= specifier inserts a record in the first empty position. A
value of -1 appends a record to the end of the file.
You can access records sequentially or directly.
1> FUP
File Utility Program - T6553D10 - (08JUN92) System \ASYS
Copyright Tandem Computers Incorporated 1981, 1983, 1985-1992
-SET TYPE E <-- Set file type
-SHOW <-- Show current values
TYPE E
EXT ( 1 PAGES, 1 PAGES )
REC 80
BLOCK 4096
MAXEXTENTS 16
-CREATE visitors <-- Create the file
CREATED - $JUICE.BUJES.VISITORS
-EXIT <-- Exit FUP
2>