The INQUIRE statement returns information on the status of specified properties of a file or logical unit. It takes one of the following forms:
The unit does not have to exist, nor does it need to be connected to a file. If the unit is connected to a file, the inquiry encompasses both the connection and the file.
The value is suitable to use as a RECL specifier value in an OPEN statement that connects a file for unformatted, direct access.
The unit of the value is 4-byte longwords, by default. However, if you specify the compiler option specifying ASSUME BYTERECL, the unit is bytes.
Rules and Behavior
The control specifiers ([UNIT=]io-unit, ERR=label, and IOSTAT=i-var) and inquiry specifiers can appear anywhere within the parentheses following INQUIRE. However, if the UNIT keyword is omitted, the io-unit must appear first in the list.
An INQUIRE statement can be executed before, during, or after a file is connected to a unit. The specifier values returned are those that are current when the INQUIRE statement executes.
To get file characteristics, specify the INQUIRE statement after opening the file.
The following are examples of INQUIRE statements:
INQUIRE (FILE='FILE_B', EXIST=EXT) INQUIRE (4, FORM=FM, IOSTAT=IOS, ERR=20) INQUIRE (IOLENGTH=LEN) A, B
In the last statement, you can use the length returned in LEN as the value for the RECL specifier in an OPEN statement that connects a file for unformatted direct access. If you have already specified a value for RECL, you can check LEN to verify that A and B are less than or equal to the record length you specified.
For More Information: