Function FileAttr

Devolve o modo de acceso ou o número de acceso do ficheiro aberto coa instrución Open. O número de acceso do ficheiro depende do sistema operativo (OSH = Operating System Handle).

Icona Nota

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


See also: Open

Sintaxe:


  FileAttr (Channel As Integer, Attributes As Integer)

Valor de retorno:

Enteiro

Parámetros:

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.

Se especifica un atributo de parámetro co valor 1, aplícanse os seguintes valores de retorno:

1 - INPUT (ficheiro aberto para entrada)

2 - OUTPUT (ficheiro aberto para saída)

4 - RANDOM (ficheiro aberto para acceso aleatorio)

8 - APPEND (ficheiro aberto para anexionar)

32 - BINARY (ficheiro aberto en modo binario).

Códigos de erro

5 Chamada de procedemento incorrecta

52 Erro no nome ou número do ficheiro

Exemplo:


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, "Esta é unha liña de texto"
    MsgBox FileAttr(#iNumber, 1), 0, "Access mode"
    MsgBox FileAttr(#iNumber, 2), 0, "File attribute"
    Close #iNumber
End Sub

Precisamos da súa axuda!