Purpose |
Return the file-system attribute(s) of a disk file or directory. | |||||||||||||||||||||||||||
Syntax |
x& = GETATTR(filespec$) | |||||||||||||||||||||||||||
Remarks |
filespec$ specifies a filename or directory (optionally, including a drive letter and directory path). The attribute code returned in x& is a standard operating system attribute code, or a combination of several codes ORed together:
* Some operating systems may return either 0 or 128 for normal files. If GETATTR returns an attribute of 0 (or 128), filespec$ is a regular file: not read-only, not hidden, not system, and not archived. Additional file attributes may be supported on some file systems. See the %FILE_ATTRIBUTE equates in your WinNT.inc file for a full list. If you want to test for a single attribute, use the bitwise AND operator to strip out any other attributes that might be set. See the example below. GETATTR can also be used to verify the existence of a file or directory, taking advantage of the fact that ERR will be set if the file/directory does not exist. See the example below. | |||||||||||||||||||||||||||
Restrictions |
If filespec$ cannot be found, a run-time Error 53 ("File not found") occurs. You cannot obtain the attributes of the root directory (i.e., "C:\"). Windows prevents this particular operation, triggering an Error 53. | |||||||||||||||||||||||||||
See also |
||||||||||||||||||||||||||||
Example |
' General GETATTR example attr& = GETATTR("C:\CONFIG.SYS") IF (attr& AND 32&) = 32& THEN x$ = "CONFIG.SYS has been modified" ELSE x$ = "CONFIG.SYS hasn't been modified" END IF |