FileAttr function
Summary
Returns information about a file opened with the Open statement — such as file access mode or file type.
Syntax
FileAttr(filenumber, returntype)
The FileAttr function syntax has these named arguments:
Part
Description
filenumberRequired; Integer. Any valid file number.
returntypeRequired; Integer. Number indicating the type of information to return. Specify 1 to return a value indicating the file mode. On 16-bit systems only, specify 2 to retrieve an operating system file handle. Returntype 2 is not supported in 32-bit systems and causes an error.
Part
Description
filenumberRequired; Integer. Any valid file number.
returntypeRequired; Integer. Number indicating the type of information to return. Specify 1 to return a value indicating the file mode. On 16-bit systems only, specify 2 to retrieve an operating system file handle. Returntype 2 is not supported in 32-bit systems and causes an error.
Example
Example
This example uses the FileAttr function to return the file mode and file handle of an open file. The file handle is returned only on 16-bit systems; on 32-bit systems, passing 2 as a second argument generates an error.
Dim FileNum, Mode, Handle
FileNum = 1 ' Assign file number.
Open "TESTFILE" For Append As FileNum ' Open file.
Mode = FileAttr(FileNum, 1) ' Returns 8 (Append file mode).
Handle = FileAttr(FileNum, 2) ' Returns file handle.
Close FileNum ' Close file.
This example uses the FileAttr function to return the file mode and file handle of an open file. The file handle is returned only on 16-bit systems; on 32-bit systems, passing 2 as a second argument generates an error.
Dim FileNum, Mode, Handle
FileNum = 1 ' Assign file number.
Open "TESTFILE" For Append As FileNum ' Open file.
Mode = FileAttr(FileNum, 1) ' Returns 8 (Append file mode).
Handle = FileAttr(FileNum, 2) ' Returns file handle.
Close FileNum ' Close file.