GETATTR is used for obtaining file attributes.
Syntax:Attribs = GETATTR(FileName AS STRING) Return Value:
Parameters:
|
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 directory 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 directory. $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 "directory" 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 directory" END IF
SETATTR is used for setting file attributes.
Syntax:SETATTR(FileName AS STRING, Attribs AS INTEGER) Parameters:
|
ISFILE is used to determine if an identifier is the name of a file.
Syntax:IsItFile = ISFILE(Identifier AS STRING) Return Value:Parameters:
|
👉 ISFILE is self-contained and should not interfere with, nor be interfered by, unrelated invocations of FINDFIRST$ or FINDNEXT$.
PRINT BOOL$(ISFILE(WINDIR$))
FALSE
ISFOLDER is used to determine if an identifier is the name of a directory.
Syntax:IsItFolder = ISFOLDER(Identifier AS STRING) Return Value:Parameters:
|
👉 ISFOLDER is self-contained and should not interfere with, nor be interfered by, unrelated invocations of FINDFIRST$ or FINDNEXT$.
PRINT BOOL$(ISFOLDER(WINDIR$))
TRUE
DIM AS STRING TheFolder TheFolder = TEMPDIR$ & "TheFolder" MKDIR(TheFolder) DIM MyFileHandle@ DIM AS STRING TheFile TheFile = TheFolder & "\TheFile" OPEN TheFile FOR OUTPUT AS FP1 MyFileHandle@ = FP1 FPRINT MyFileHandle@, "This is " & TheFile CLOSE FP1 PRINT PRINT "It is ", BOOL$(ISFOLDER(TheFolder)), " that ", TheFolder, " is a folder." PRINT "It is ", BOOL$(ISFILE(TheFile)), " that ", TheFile, " is a file." PRINT KILL TheFile IF NOT EXIST(TheFile) THEN PRINT "The file ", TheFile, " has been removed." ELSE PRINT "The file ", TheFile, " could not be removed." END IF PRINT IF NOT RMDIR(TheFolder) THEN PRINT "RMDIR removed the folder " & TheFolder ELSE PRINT "RMDIR could not remove the folder " & TheFolder END IF PAUSE
It is True that C:\Users\YouSir\AppData\Local\Temp\TheFolder is a folder. It is True that C:\Users\YouSir\AppData\Local\Temp\TheFolder\TheFile is a file. The file C:\Users\YouSir\AppData\Local\Temp\TheFolder\TheFile has been removed. RMDIR removed the folder C:\Users\YouSir\AppData\Local\Temp\TheFolder Press any key to continue . . .
ISHIDDEN is used to determine if an identifier is the name of a hidden file/directory.
Syntax:IsItHidden = ISHIDDEN(Identifier AS STRING) Return Value:Parameters:
|
👉 ISHIDDEN is self-contained and should not interfere with, nor be interfered by, unrelated invocations of FINDFIRST$ or FINDNEXT$.
PRINT BOOL$(ISHIDDEN(ENVIRON$("USERPROFILE") & "\AppData"))
TRUE
ISREADONLY is used to determine if an identifier is the name of a read only file/directory.
Syntax:IsItReadOnly = ISREADONLY(Identifier AS STRING) Return Value:Parameters:
|
👉 ISREADONLY is self-contained and should not interfere with, nor be interfered by, unrelated invocations of FINDFIRST$ or FINDNEXT$.
PRINT BOOL$(ISREADONLY(WINDIR$))
TRUE
ISSYSTEM is used to determine if an identifier is the name of a system file/directory.
Syntax:IsItSystem = ISSYSTEM(Identifier AS STRING) Return Value:Parameters:
|
👉 ISSYSTEM is self-contained and should not interfere with, nor be interfered by, unrelated invocations of FINDFIRST$ or FINDNEXT$.
PRINT BOOL$(ISSYSTEM(WINDIR$))
TRUE