GETATTR.md 3.7 KB

GETATTR function

Purpose: Used for obtaining file attributes.


 Syntax:

 Attribs% = GETATTR(FileName$)

 Parameters:

  • Attribs% Returned value that is a combination of
    • A read-only file
      FILE_ATTRIBUTE_READONLY = 1
    • A hidden file, not normally visible to the user.
      FILE_ATTRIBUTE_HIDDEN = 2
    • A system file, used exclusively by the operating system.
      FILE_ATTRIBUTE_SYSTEM = 4
    • A folder instead of a file.
      FILE_ATTRIBUTE_DIRECTORY = 16
    • An archive file(which most files are).
      FILE_ATTRIBUTE_ARCHIVE = 32
    • An attribute-less file(cannot be combined with other attributes).
      FILE_ATTRIBUTE_NORMAL = 128
    • A file being used for temporary storage
      FILE_ATTRIBUTE_TEMPORARY = 256
    • A file residing in a compressed drive or folder.
      FILE_ATTRIBUTE_COMPRESSED = 2048
  • FileName$ Name of file from which attributes are to be obtained.

Example:


 DIM attribs%
 DIM int1%
 
 $COMMENT
  FILE_ATTRIBUTE_READONLY = 1 
  A read-only file.
 
  FILE_ATTRIBUTE_HIDDEN = 2 
  A hidden file.
 
  FILE_ATTRIBUTE_SYSTEM = 4
  A system file, used by the operating system.
 
  FILE_ATTRIBUTE_DIRECTORY = 16 
  A folder instead of a file.
 
  FILE_ATTRIBUTE_ARCHIVE = 32 
  An archive flag marking a file for backup.
 
  FILE_ATTRIBUTE_NORMAL = 128 
  A file with no attributes.
 
  FILE_ATTRIBUTE_COMPRESSED = 2048 
  A file in a compressed drive or folder.
 $COMMENT
 
 attribs% = GETATTR("myfile.bas")  ' read file attributes
 
 int1% = attribs% AND FILE_ATTRIBUTE_READONLY
 IF int1% <> 0 THEN
   PRINT "Read-only"
 END IF
 
 int1% = attribs% AND FILE_ATTRIBUTE_HIDDEN
 IF int1% <> 0 THEN
   PRINT "Hidden"
 END IF
 
 int1% = attribs% AND FILE_ATTRIBUTE_SYSTEM
 IF int1% <> 0 THEN
   PRINT "System"
 END IF
 
 int1% = attribs% AND FILE_ATTRIBUTE_DIRECTORY
 IF int1% <> 0 THEN
   PRINT "Folder"
 END IF
 
 int1% = attribs% AND FILE_ATTRIBUTE_ARCHIVE
 IF int1% <> 0 THEN
   PRINT "Archive flag set"
 END IF
 
 int1% = attribs% AND FILE_ATTRIBUTE_NORMAL
 IF int1% <> 0 THEN
   PRINT "Normal, no other attributes set"
 END IF
 
 int1% = attribs% AND FILE_ATTRIBUTE_COMPRESSED
 IF int1% <> 0 THEN
   PRINT "File in Compressed Drive or Folder"
 END IF
 

BCX Console Sample Programs using GETATTR function.

S67.bas

SETATTR statement

Purpose: SETATTR is used for setting file attributes.


 Syntax:

 SETATTR(FileName$, Attribs%)

 Parameters:

  • FileName$ Name of file in which attributes are to be set.
  • Attribs% Attributes value to be set which is a combination of
    • A read-only file
      FILE_ATTRIBUTE_READONLY = 1
    • A hidden file, not normally visible to the user.
      FILE_ATTRIBUTE_HIDDEN = 2
    • A system file, used exclusively by the operating system.
      FILE_ATTRIBUTE_SYSTEM = 4
    • An archive file(which most files are).
      FILE_ATTRIBUTE_ARCHIVE = 32
    • An attribute-less file(cannot be combined with other attributes).
      FILE_ATTRIBUTE_NORMAL = 128
    • A file being used for temporary storage
      FILE_ATTRIBUTE_TEMPORARY = 256