Software Archive
Read-only legacy content
17060 ディスカッション

Record Length

Intel_C_Intel
従業員
1,013件の閲覧回数
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
0 件の賞賛
3 返答(返信)
Steven_L_Intel1
従業員
1,013件の閲覧回数
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
sabalan
新規コントリビューター I
1,013件の閲覧回数
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.
Intel_C_Intel
従業員
1,013件の閲覧回数
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
返信