SetAttr (statement)

Syntax SetAttr filename$,attribute
Description Changes the attribute filename$ to the given attribute. A runtime error results if the file cannot be found.
Comments The SetAttr statement accepts the following parameters:
Parameter Description
filename$ String containing the name of the file.
attribute Integer specifying the new attribute of the file.
The attribute parameter can contain any combination of the following values:
Constant Value Description
ebNormal 0 Turns off all attributes
ebReadOnly 1 Read-only files
ebHidden 2 Hidden files
ebSystem 4 System files
ebVolume 8 Volume label
ebArchive 32 Files that have changed since the last backup
ebNone 64 Turns off all attributes
The attributes can be combined using the + operator or the binary Or operator.
Example This example creates a file and sets its attributes to Read-Only and System.
Sub Main()
  Open "test.dat" For Output As #1
  Close #1
  MsgBox "The current file attribute is: " & GetAttr("test.dat")
  SetAttr "test.dat",ebReadOnly + ebSystem
  MsgBox "The file attribute was set to: " & GetAttr("test.dat")
  SetAttr "test.dat",ebNormal
  Kill "test.dat"
End Sub
See Also GetAttr (function); FileAttr (function).