The INQUIRE statement returns information on the status of specified properties of a file or logical unit. It takes one of the following forms:
INQUIRE (FILE=name [,ERR=label] [,IOSTAT=i-var] [,DEFAULTFILE=def] ,slist)
INQUIRE ([UNIT=]io-unit [,ERR=label] [,IOSTAT=i-var], slist)
INQUIRE (IOLENGTH=len) out-item-list
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 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.
To inquire about a file using the DEFAULTFILE specifier, the
specifier must also appear in the OPEN statement for that file.
You can specify DEFAULTFILE=def in addition to (or in place of)
FILE=name, and the name and def can start with a
tilde (~).
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.