Operating System - OpenVMS
1751969 Members
4702 Online
108783 Solutions
New Discussion

Re: issues with f$file_format lexical function

 
Hein_vdHeuvel_d
Advisor

Re: issues with f$file_format lexical function

Thank you cachaza for your contribution. It is clear enough.

 

You are correct, IF-and-only-IF, the file is fixed length record sequential then you can calculate the number of records from eof-block * 512 + ffb / size. 

Note: Size should be picked up from LRL, not MRS, and should be rounded up to even value before dividing.

I the file is larger than 2GB (4194303 blocks) you indeed need a (cobol) helper program to do the math with more than 32 bits, but for most files you can just use DCL divides.

 

Too bad that RMS does not do file-length-hints for this easy file type huh!

 

I had an Email exchange with John... Searching for and empty string makes sure that there is an immediate hit for each record, so that's quicker and lookign at each bytes. Also, this avoids the 'no match found' message to sys$error.

 

Cheers,

Hein

 

 

 

H.Becker
Honored Contributor

Re: issues with f$file_format lexical function

COMPUTE NUM-REG ROUNDED = (((( PAR-EOF9 - 1 ) * 512 ) + PAR-FFB9 ) / PAR-MRS9 )

 

>You are correct, IF-and-only-IF, the file is fixed length record sequential then you can calculate the number of records from eof-block * 512 + ffb / size. 

 

The right formula - subtracting 1 or not - depends on ffb. The one in your Cobol source is correct for ffb>0. The other one  - insert the appropriate parentheses - is correct for ffb==0 (which makes the addition somehow obsolete).

 

$ f:=whatever
$ cre 'f
whatever
 Exit 
$ write sys$output f$file(f,"eof")
1
$ write sys$output f$file(f,"ffb")
10
$ ! here rfm=var and the file size is 10: (eof-1)*512+ffb
$ convert/fdl=tt: 'f 'f.fix/pad=%x20
FILE
ORGANIZATION            sequential
RECORD
CARRIAGE_CONTROL none
FORMAT fixed
SIZE 512
 Exit 
$ write sys$output f$file(f+".fix","eof")
1
$ write sys$output f$file(f+".fix","ffb")
0
$ ! the file size is 512: eof*512+ffb