HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get file size in symbol var

 
File size
Occasional Visitor

How to get file size in symbol var

i want to know that how to get a file size in blocks in symbol directly
Can this possible?
If yes , then how? please give me reply..
3 REPLIES
Graham Burley
Frequent Advisor

Re: How to get file size in symbol var

$ n = f$file("LOGIN.COM","EOF")
$ sho sym n
N = 5 Hex = 00000005 Octal = 00000000005

$ help lex f$file_attributes
Willem Grooters
Honored Contributor

Re: How to get file size in symbol var

The answer is, indeed, lexical function F$FileAttributes, but there is more to take into account.

First, you'll need to know what type of file it is: sequential, relative or indexed.

option ORG gives you that answer.

Next, ask yourself what size you are interested in: Allocated (always a multiple of the disk's clsutersize) or the really used space.
Allocated size works regardless organization: Option ALQ will pas that information into the symbol. Bear in mind the result is returned in 512-byte blocks, so if you need to have it in bytes, multiply the value by 512.

REAL size depends on the file's organization.
For seqeuntial files, it can be determined by options EOF and FFB. The first will return the number of fully used 512-byte blocks, the second the offset of the first free byte in the next block: In bytes, the size therefore is (value returned by EOF * 512) + value returned by FFB.

For indexed and relative files, I would recommend usage of allocated size, since calculating the real size is far more complex and will require extra (internal) information that is not easily obtained.

Willem Grooters
OpenVMS Developer & System Manager
Jess Goodman
Esteemed Contributor

Re: How to get file size in symbol var

There is one restriction with F$FILE_ATTRIBUTES - it can not be used on a file that is opened for exclusive access (no read sharing). If you attempt to you will get the error:

%SYSTEM-W-ACCONFLICT, file access conflict

So in some cases to check a file's size you may have to either have to parse DIRECTORY output, or write your own program that does the same thing.
I have one, but it's personal.