- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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
コピーされたリンク
3 返答(返信)
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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