FileAttr funkcija

Grąžina failo, atverto naudojant atvėrimo sakinį, prieigos veikseną arba failo prieigos numerį. Failo prieigos numeris priklauso nuo operacinės sistemos (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.


Dar žr.: Atverti

Sintaksė:


  FileAttr (Channel As Integer, Attributes As Integer)

Grąžinimo reikšmė:

Sveikasis skaičius

Parametrai:

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.

Jei nurodote parametro atributą, kurio reikšmė yra 1, taikomos šios grąžinimo reikšmės:

1 - INPUT (failas atvertas įvedimui)

2 - OUTPUT (failas atvertas išvedimui)

4 - RANDOM (failas atvertas atsitiktinei prieigai)

8 - APPEND (failas atvertas pridėjimui)

32 - BINARY (failas atvertas dvejetaine veiksena).

Klaidos kodai:

5 Neteisingas procedūros iškvietimas

52 neteisingas failo pavadinimas arba failo numeris

Pavyzdys:


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, "Tai teksto eilutė"
    MsgBox FileAttr(#iNumber, 1), 0, "Access mode"
    MsgBox FileAttr(#iNumber, 2), 0, "File attribute"
    Close #iNumber
End Sub

Paremkite mus!