Just starting out? Need help? Post your questions and find answers here.
Fangbeast
PureBasic Protozoa
Posts: 4792 Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)
Post
by Fangbeast » Mon May 05, 2003 7:23 am
In the PB help, it explains how to return just one attribute using the & symbol. How do you return multiple attributes with pb this way?
I use the below code to return a single attribute from a file but if a file has more than one attribute set; or none; I don't know how to do it.
And I set a text mask for the user as you can see:)
Code: Select all
Mattribute = DirectoryEntryAttributes()
If Mattribute & #PB_FileSystem_Normal : Attributes.s = "-----"
ElseIf Mattribute & #PB_FileSystem_ReadOnly : Attributes.s = "R----"
ElseIf Mattribute & #PB_FileSystem_Archive : Attributes.s = "-A---"
ElseIf Mattribute & #PB_FileSystem_System : Attributes.s = "--S--"
ElseIf Mattribute & #PB_FileSystem_Hidden : Attributes.s = "---H-"
ElseIf Mattribute & #PB_FileSystem_Compressed : Attributes.s = "----C"
EndIf
Amateur Radio/VK3HAF , (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
PB
PureBasic Expert
Posts: 7581 Joined: Fri Apr 25, 2003 5:24 pm
Post
by PB » Mon May 05, 2003 8:06 am
You were already close, but you were not testing for multiple flags (due to ElseIf).
Here's a very quick'n'dirty API example (there's definitely better ways):
Code: Select all
Procedure.s GetAttributes(file$)
r=GetFileAttributes_(file$)
If r & #FILE_ATTRIBUTE_ARCHIVE : a$+"A" : Else : a$+"-" : EndIf
If r & #FILE_ATTRIBUTE_COMPRESSED : a$+"C" : Else : a$+"-" : EndIf
If r & #FILE_ATTRIBUTE_DIRECTORY : a$+"D" : Else : a$+"-" : EndIf
If r & #FILE_ATTRIBUTE_HIDDEN : a$+"H" : Else : a$+"-" : EndIf
If r & #FILE_ATTRIBUTE_READONLY : a$+"R" : Else : a$+"-" : EndIf
If r & #FILE_ATTRIBUTE_SYSTEM : a$+"S" : Else : a$+"-" : EndIf
ProcedureReturn a$
EndProcedure
;
Debug GetAttributes("c:\autoexec.bat")
BTW, there's no "normal" flag up there because mask$ would simply be "-----" for such a file.
Last edited by
PB on Thu Sep 04, 2003 1:28 am, edited 1 time in total.
Fangbeast
PureBasic Protozoa
Posts: 4792 Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)
Post
by Fangbeast » Mon May 05, 2003 8:17 am
I work on the principle of plugin technology. If yours works and mine doesn't, I plug yours in and worry about the "better way" later. (Much later)
:roll:
Been adding (plugging in) bits and pieces for a dumb file manager that I want to test for other programs. Fun program so far:)
Thanks PB.
Amateur Radio/VK3HAF , (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet