Contents

# 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).

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

Skatiet arī: Open

### Syntax:

      FileAttr (Channel As Integer, Attributes As Integer)

### Return type:

Vesels skaitlis

### Parameters:

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

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

1: FileAttr indicates the access mode of the file.

2: FileAttr 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:

1 - INPUT (datnes atvēršana ievadei)

2 - OUTPUT (datnes atvēršana izvadei)

4 - RANDOM (datnes atvēršana nejaušai piekļuvei)

8 - APPEND (file open for appending)

32 - BINARY (datnes atvēršana binārajā režīmā).

### Error codes:

5 Nederīgs procedūras izsaukums

52 Nederīgs datnes nosaukums vai datnes numurs

### Example:

    Sub ExampleFileAttr
        Dim iNumber As Integer
        Dim sLine As String
        Dim aFile As String
        aFile = "C:\Users\ThisUser\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

Saistītie temati

Close Statement

FreeFile Function

Open Statement

Print# Statement

Please support us!