FSTAT function returns a structure expression of type FSTAT containing status information about a specified
file unit. The contents of this structure are documented in
The FSTAT Function
Result = FSTAT(
The file unit about which information is required. This parameter can be an integer or an associated variable, in which case information about the variable's associated file is returned.
Fields of the
The following descriptions are of
in the structure returned by the FSTAT function. They are
keywords to FSTAT.
The IDL logical unit number (LUN).
The name of the file.
Nonzero if the file unit is open. If OPEN is zero, the remaining fields in FSTAT will not contain useful information.
Nonzero if the file is actually a terminal instead of a normal file. For example, if you are using an
window on a Unix system and you invoke FSTAT on logical unit 0 (standard input), ISATTY will be set to 1.
Nonzero if the file is actually a Graphical User Interface (for example, a logical unit associated with the IDL Development Environment). Thus, if you are using the IDLDE and you invoke FSTAT on logical unit 0 (standard input), ISAGUI will be set to 1.
ISATTY or ISAGUI is nonzero.
Nonzero if the file is open for read access.
Nonzero if the file is open for write access.
The number of scalar IDL data items transferred in the last input/output operation on the unit. This is set by the following IDL routines: READU, WRITEU, PRINT, PRINTF, READ, and READF. TRANSFER_COUNT is useful when attempting to recover from input/output errors.
The current position of the
file pointer, given in bytes from the start of the file. If the device is a terminal (ISATTY is nonzero), the value of CUR_PTR will not contain useful information.
The current length of the
file in bytes. If the device is a terminal (ISATTY is nonzero), the value of SIZE will not contain useful information.
VMS variable length records have a 2-byte record-length descriptor at the beginning of each record. Because the SIZE field contains the length of the data file
the record descriptors, reading a file with VMS variable length records into a byte array of the size returned by FSTAT will result in an RMS EOF error.
If the file is record-oriented (VMS), this field contains the
record length; otherwise, it is zero.
If file unit number 1 is open, the FSTAT information on that unit can be seen by entering:
Specific information can be obtained by referring to single fields within the structure returned by FSTAT. The following code prints the name and length of the file open on unit 1:
A = FSTAT(1)
PRINT, 'File: ', A.NAME, ' is ', A.SIZE, ' bytes long.'