FileAttr Function

Returns the access mode or the file access number of a file that was opened with the Open statement. The file access number is dependent on the operating system (OSH = Operating System Handle).

Note Icon

If you use a 32-Bit operating system, you cannot use the FileAttr-Function to determine the file access number.


See also: Open

Syntax:


FileAttr (FileNumber As Integer, Attribute As Integer)

рд╡рд╛рдкрд╕реА рдореВрд▓реНрдп:

рдкреВрд░реНрдгрд╛рдВрдХ

рдкреИрд░рд╛рдореАрдЯрд░

FileNumber: The number of the file that was opened with the Open statement.

Attribute: Integer expression that indicates the type of file information that you want to return. The following values are possible:

1: FileAttr-рдлрд╝рдВрдХреНрд╢рди рдлрд╝рд╛рдЗрд▓ рдХрд╛ рдПрдХреНрд╕реЗрд╕ рдореЛрдб рдЗрдВрдЧрд┐рдд рдХрд░рддрд╛ рд╣реИ.

2: The FileAttr-Function returns the file access number of the operating system.

If you specify a parameter attribute with a value of 1, the following return values apply:

2 - OUTPUT ( рдЖрдЙрдЯрдкреБрдЪ рдХреЗ рд▓рд┐рдП рдлрд╝рд╛рдЗрд▓ рдЦреБрд▓рд╛ рд╣реИ)

2 - OUTPUT ( рдЖрдЙрдЯрдкреБрдЪ рдХреЗ рд▓рд┐рдП рдлрд╝рд╛рдЗрд▓ рдЦреБрд▓рд╛ рд╣реИ)

4 - RANDOM (file open for random access)

8 - APPEND (file open for appending)

32 - BINARY (file open in binary mode).

Error codes:

5 Invalid procedure call

52 Invalid file name or file number

рдЙрджрд╛рд╣рд░рдг:


Sub ExampleFileAttr
Dim iNumber As Integer
Dim sLine As String
Dim aFile As String
    aFile = "c:\data.txt"
    iNumber = Freefile
    Open aFile For Output As #iNumber
    Print #iNumber, "This is a line of text"
    MsgBox FileAttr(#iNumber, 1 ),0,"Access mode"
    MsgBox FileAttr(#iNumber, 2 ),0,"File attribute"
    Close #iNumber
End Sub