GetAttr Function

Returns an Integer representing the attributes of a file, directory, or folder.

Syntax

GetAttr(path)

Remarks

The required path argument is a string expression that specifies a file name. The path may include the directory or folder, and the drive.

Return Values

The value returned by GetAttr is the sum of the following attribute values:

Constant Value Description
cdbNormal 0 Normal
cdbHidden 2 Hidden
cdbSystem 4 System (Microsoft Windows only)
cdbDirectory 16 Directory or folder
cdbArchive 32 File has changed since last backup (Microsoft Windows only)
cdbAlias 64

File name is an alias (Macintosh only)


Remarks

To determine which attributes are set, use the And operator to perform a bitwise comparison of the value returned by the GetAttr function and the value of the individual file attribute you want. If the result is not zero, that attribute is set for the named file. For example, the return value of the following And expression is zero if the Archive attribute is not set:

Result = GetAttr(FName) And cdbArchive

A nonzero value is returned if the Archive attribute is set.

Example

This example uses the GetAttr function to determine the attributes of a file and directory or folder.

Dim MyAttr
' Assume file TESTFILE has hidden attribute set. MyAttr = GetAttr("TESTFILE") ' Returns 2. ' Returns nonzero if hidden attribute is set on TESTFILE.
Trace MyAttr And cdbHidden ' Assume file TESTFILE has hidden and read-only attributes set. MyAttr = GetAttr("TESTFILE") ' Returns 3. ' Returns nonzero if hidden and read-only attributes are set on TESTFILE.
Trace MyAttr And (cdbHidden + cdbReadOnly) ' Assume MYDIR is a directory or folder.
MyAttr = GetAttr("MYDIR") ' Returns 16.

See Also

SetAttr Statement, And Operator , FileAttr Function