- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I want to open an existing direct access unformatted file, whose record length I don't know. In which way I can get the record legth for OPEN statement. Following does not work, because it returns always 0 or 132.
INQUIRE(FILE=FNAME,RECL=LRL_H)
The file has been created as follows:
OPEN(LU, ACCESS='DIRECT', ERR=999, FILE=FNAME,
& FORM='UNFORMATTED', STATUS='NEW', RECORDTYPE='FIXED',
& RECL=LRL_H)
Thanks! KK
I want to open an existing direct access unformatted file, whose record length I don't know. In which way I can get the record legth for OPEN statement. Following does not work, because it returns always 0 or 132.
INQUIRE(FILE=FNAME,RECL=LRL_H)
The file has been created as follows:
OPEN(LU, ACCESS='DIRECT', ERR=999, FILE=FNAME,
& FORM='UNFORMATTED', STATUS='NEW', RECORDTYPE='FIXED',
& RECL=LRL_H)
Thanks! KK
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There's no way to do this reliably - the record length is not stored in the file. If you have some idea of the length, you can see if it is an integral divisor of the file size in bytes (keep in mind that unformatted RECL values are in units of 4 bytes.)
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was just wondering: Shouldn't you open the file with STATUS='OLD' if it is an EXISTING file you are trying to open?
Regards,
Sabalan.
Regards,
Sabalan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the record length has been written into a direct access file, it can be opened correctly with two subsequent OPEN calls. Consider following simple example:
WRITE(LU,REC=1) Rec_len
CLOSE(LU)
IRECL = 256
OPEN(LU,ACCESS='DIRECT',ERR=999,FILE=FNAME,
& FORM='UNFORMATTED',STATUS='OLD',RECL=IRECL)
READ(LU,REC=1) Rec_len
CLOSE(LU)
OPEN(LU,ACCESS='DIRECT',ERR=999,FILE=FNAME,
& FORM='UNFORMATTED',STATUS='OLD',RECL=Rec_len)
This is, of course, possible if the record length has been written into the file. It is not necessary that it is the first item in the first record, but thus makes things easier.
Kari K
WRITE(LU,REC=1) Rec_len
CLOSE(LU)
IRECL = 256
OPEN(LU,ACCESS='DIRECT',ERR=999,FILE=FNAME,
& FORM='UNFORMATTED',STATUS='OLD',RECL=IRECL)
READ(LU,REC=1) Rec_len
CLOSE(LU)
OPEN(LU,ACCESS='DIRECT',ERR=999,FILE=FNAME,
& FORM='UNFORMATTED',STATUS='OLD',RECL=Rec_len)
This is, of course, possible if the record length has been written into the file. It is not necessary that it is the first item in the first record, but thus makes things easier.
Kari K

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page