FileAttr Function

āĻ“āĻĒ⧇āύ āĻ¸ā§āĻŸā§‡āϟāĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āĻ–ā§‹āϞāĻž āĻāĻ•āϟāĻŋ āĻĢāĻžāχāϞ⧇āϰ āĻĒā§āĻ°ā§Ÿā§‹āĻ—āύ āĻŽā§‹āĻĄ āĻ…āĻĨāĻŦāĻž āĻĢāĻžāχāϞ āĻĒā§āĻ°ā§Ÿā§‹āĻ— āĻ•ā§āϰāĻŽ āĻĒā§āϰāĻĻāĻžāύ āĻ•āϰ⧇ āĻĨāĻžāϕ⧇āĨ¤ āĻĢāĻžāχāϞ āĻĒā§āĻ°ā§Ÿā§‹āĻ— āĻ•ā§āϰāĻŽāϟāĻŋ āĻ…āĻĒāĻžāϰ⧇āϟāĻŋāĻ‚ āϏāĻŋāĻ¸ā§āĻŸā§‡āĻŽā§‡āϰ āωāĻĒāϰ āύāĻŋāĻ°ā§āĻ­āϰāĻļā§€āϞ (OSH = Operating System Handle)āĨ¤

āύ⧋āϟ āφāχāĻ•āύ

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


āφāϰāĻ“ āĻĻ⧇āϖ⧁āύ: āϖ⧁āϞ⧁āύ

Syntax:


  FileAttr (Channel As Integer, Attributes As Integer)

Return value:

Integer

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.

āφāĻĒāύāĻŋ āϝāĻĻāĻŋ āĻŽāĻžāύ ā§§ āϏāĻšāĻ•āĻžāϰ⧇ āĻāĻ•āϟāĻŋ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ⧇āϰ āĻŦ⧈āĻļāĻŋāĻˇā§āĻŸā§āϝ āωāĻ˛ā§āϞ⧇āĻ– āĻ•āϰ⧇āύ, āϤāĻžāĻšāϞ⧇ āύāĻŋāĻšā§‡āϰ āĻĒā§āϰāĻĻāĻžāύ āĻŽāĻžāύ āĻĒā§āĻ°ā§Ÿā§‹āĻ— āĻšā§Ÿ:

1 - INPUT (āχāύāĻĒ⧁āĻŸā§‡āϰ āϜāĻ¨ā§āϝ āĻĢāĻžāχāϞāϟāĻŋ āĻ–ā§‹āϞāĻž)

2 - OUTPUT (āφāωāϟāĻĒ⧁āĻŸā§‡āϰ āϜāĻ¨ā§āϝ āĻĢāĻžāχāϞāϟāĻŋ āĻ–ā§‹āϞāĻž)

4 - RANDOM (āĻ°â€ā§āϝāĻžāĻ¨ā§āĻĄāĻŽ āĻĒā§āĻ°ā§Ÿā§‹āϗ⧇āϰ āϜāĻ¨ā§āϝ āĻĢāĻžāχāϞ āωāĻ¨ā§āĻŽā§āĻ•ā§āϤ)

8 - APPEND (āĻĒāϰāĻŋāĻļ⧇āώ⧇ āϝ⧋āĻ— āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻĢāĻžāχāϞāϟāĻŋ āĻ–ā§‹āϞāĻž)

32 - BINARY (āĻŦāĻžāχāύāĻžāϰ⧀ āĻŽā§‹āĻĄā§‡ āĻĢāĻžāχāϞāϟāĻŋ āĻ–ā§‹āϞāĻž)āĨ¤

Error codes:

5 Invalid procedure call

52 Bad file name or number

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

Please support us!