FORTRAN Reference Manual

Introduction to File I/O in the HP NonStop
Environment
FORTRAN Reference Manual528615-001
5-22
Structured Files
The following example shows how to create the key-sequenced file VENDORS.
The following statement opens the VENDORS file:
OPEN(22, file='vendors', STATUS= 'OLD', ACCESS='SEQUENTIAL',
& FORM='FORMATTED')
The following statement writes a record to the file:
WRITE(22, FMT=30) name, address, amount, discount
You can position the file for a subsequent read or write:
READ *, name
POSITION(22, KEY=name, MODE='EXACT')
Using Alternate Keys
To use alternate keys to access data in a structured file, you must use FUP SET
commands to:
Define a two-letter key specifier that identifies the alternate key as an access path
for positioning the file.
Define the record offset where the alternate-key field begins.
Define the length of the alternate key field.
Create an alternate-key file for each structured file having one or more alternate
keys.
The following record in the relative file SALES can be accessed by alternate keys:
1> FUP
File Utility Program - T6553D10 - (08JUN92) System \ASYS
Copyright Tandem Computers Incorporated 1981, 1983, 1985-1992
-SET TYPE K <-- Set file type
-SET REC 120 <-- Set record length
-SET KEYLEN 24 <-- Set primary key length
-SHOW <-- Show values
TYPE K
EXT ( 1 PAGES, 1 PAGES )
REC 120
BLOCK 4096
IBLOCK 4096
KEYLEN 24
KEYOFF 0
MAXEXTENTS 16
-CREATE vendors <-- Create file
CREATED - $JUICE.BUJES.VENDORS
-EXIT <-- Exit FUP
2>