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!