Syntax
|
FileAttr
(filenumber, attribute)
|
Description
|
Returns an
Integer
specifying the file mode (if attribute is 1) or the operating system file handle (if attribute is 2).
|
Comments
|
The
FileAttr
function takes the following parameters:
|
|
Parameter
|
Description
|
|
Filenumber
|
Integer value used by Basic Control Engine to refer to the open file; the number passed to the Open statement.
|
|
Attribute
|
Integer specifying the type of value to be returned. If attribute is 1, then one of the following values is returned:
|
|
|
1
|
Input
|
|
|
2
|
Output
|
|
|
4
|
Random
|
|
|
8
|
Append
|
|
|
32
|
Binary
|
|
|
If attribute is 2, then the operating system file handle is returned. On most systems, this is a special
Integer
value identifying the file.
|
Example
|
This example opens a file for input, reads the file attributes, and determines the file mode for which it was opened. The result is displayed in a dialog box.
Sub Main()
Open "c:\autoexec.bat" For Input As #1
a% = FileAttr(1,1)
Select Case a%
Case 1
MsgBox "Opened for input."
Case 2
MsgBox "Opened for output."
Case 4
MsgBox "Opened for random."
Case 8
MsgBox "Opened for append."
Case 32
MsgBox "Opened for binary."
Case Else
MsgBox "Unknown file mode."
End Select
a% = FileAttr(1,2)
MsgBox "File handle is: " & a%
Close
End Sub
|
See Also
|
FileLen (function); GetAttr (function); FileExists (function); Open (statement); SetAttr (statement).
|