Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
INQUIRE
◄Up► ◄Contents► ◄Index► ◄Back►
─────INQUIRE────────────────────────────────────────────────────────────────
Action
Returns the properties of a unit or external file.
Syntax
INQUIRE ({[UNIT=]unitspec | FILE=file}
[ , ACCESS=access]
[ , BINARY=binary]
[ , BLANK=blank]
[ , BLOCKSIZE=blocksize]
[ , DIRECT=direct]
[ , ERR=errlabel]
[ , EXIST=exist]
[ , FORM=form]
[ , FORMATTED=formatted]
[ , IOSTAT=iocheck]
[ , IOFOCUS=focus]
[ , MODE=mode]
[ , NAME=name]
[ , NAMED=named]
[ , NEXTREC=nextrec]
[ , NUMBER=num]
[ , OPENED=opened]
[ , RECL=recl]
[ , SEQUENTIAL=seq]
[ , SHARE=share]
[ , UNFORMATTED=unformatted])
If UNIT= is omitted, <unitspec> must be the first parameter. The
parameters can otherwise appear in any order.
Parameter Description
unitspec An integer expression or an asterisk (*) specifying
an external unit. If UNIT = * is specified, you may
not include the NUMBER= option. <unitspec> or <file>
must be specified, but not both. If <unitspec> is
given, the inquiry is "by-unit."
file A character expression containing the name of a
file. <unitspec> or <file> must be specified, but
not both. If <file> is given, the inquiry is
"by-file."
access A character variable that returns 'SEQUENTIAL' or
'DIRECT' depending on the file's access type. In an
inquire-by-unit operation, if no file is connected
to <unitspec>, <access> is undefined.
binary A character variable, array element, or structure
element. Is set to 'YES' if binary is among the
allowable forms for the specified file or unit.
Is set to 'NO' or 'UNKNOWN' otherwise.
blank A character variable that returns 'NULL' if the BN
edit descriptor is in effect. Returns 'ZERO' if BZ
is in effect.
blocksize An integer variable that returns the I/O buffer
size if the unit or file is connected. If it is not
connected, <blocksize> is undefined.
direct A character variable that returns 'YES' if direct
is among the allowable access modes. Returns 'NO'
or 'UNKNOWN' otherwise.
errlabel The label of an executable statement in
the same program unit. An I/O error causes
transfer of control to the statement at
<errlabel>. If <errlabel> is omitted, the
effect of an I/O error is determined by the
presence or absence of <iocheck>.
exist A logical variable that returns .TRUE. if the unit
or file exists or .FALSE. otherwise.
focus A logical value. If the value is .TRUE., the
child window receives focus prior to each
READ or WRITE to that unit.
form A character variable that returns 'FORMATTED' if
the unit or file is connected for formatted I/O,
'UNFORMATTED' for unformatted I/O, and 'BINARY' for
binary I/O.
formatted A character variable that returns 'YES' if
formatted is an allowable form. Returns 'NO' or
'UNKNOWN' otherwise.
iocheck An integer variable that returns zero if there
is no error, or the error number if an error occurs.
iofocus A logical variable, array element, or structure
element that returns a value of .TRUE. if the
specified unit has the current I/O focus (is
the active window) in a QuickWin application.
If the unit does not have the current I/O focus,
the return value is .FALSE.
mode A character variable, that returns the current mode
status. Possible modes are: OPEN statement: 'READ',
'WRITE', and 'READWRITE'. If no file is connected in
an inquire-by-unit operation, <mode> is undefined.
name A character variable that returns the name of the
file connected to <unitspec> in an inquire-by-unit
operation. If no file is connected, or if the file
does not have a name, <name> is undefined. In an
inquire-by-file operation, returns the name of the
file.
named A logical variable that returns .FALSE. if the file
unit is not open or if it is a scratch file; returns
.TRUE. otherwise.
nextrec An integer variable that returns the record
number of the next record in a direct-access
file.
num An integer variable that returns the number of
the unit connected to <file>. If no unit is
defined in an inquire-by file operation, <num>
is undefined. Do not include this option if you
specify UNIT = * or a run-time error occurs.
opened A logical variable that in an inquire-by-unit
operation, returns .TRUE. if a file is currently
connected or returns .FALSE. otherwise. In an
inquire-by-file operation, it returns .TRUE. if
<file> is currently connected to any unit, or
.FALSE. otherwise.
recl An integer variable that returns the length, in
bytes, of each record in a direct-access file.
seq A character variable that returns 'YES' if
sequential is an allowable access mode. Returns 'NO'
or 'UNKNOWN' otherwise.
share A character variable that returns the current share
status. Possible status values are: 'COMPAT',
'DENYRW', 'DENYWR', 'DENYRD', and 'DENYNONE'. If
no file is connected in an inquire-by-unit
operation, <share> is undefined.
unformatted A character variable that returns 'YES' if
unformatted is an allowable form. Returns 'NO' or
'UNKNOWN' otherwise.
Remarks
INQUIRE returns the attributes of an open file.
If a parameter is an expression that calls a function, that function
must not execute an I/O statement or the EOF intrinsic function.
Calling these functions causes unpredictable results.
Example
C This program prompts for the name of a data file. The INQUIRE
C statement then determines whether or not the file exists.
C If it does not, the program prompts for another file name.
CHARACTER*12 fname
LOGICAL exists
C Get the name of a file:
100 WRITE (*, '(1X, A\)') 'Enter the file name: '
READ (*, '(A)') fname
C INQUIRE about file's existence:
INQUIRE (FILE = fname, EXIST = exists)
IF (.NOT. exists) THEN
WRITE (*,'(2A/)') ' > Cannot find file ', fname
GOTO 100
END IF
.
.
.
END
-♦-