
(OffsetOf(FILEITEM\Name)), which is a string value ( #PB_String).

If there are some entries in the list, show the results in the debug window.Īnd resorts it into ascending order ( #PB_Sort_Ascending), of the Name field of the structure SortStructuredList( Files(), #PB_Sort_Ascending, OffsetOf(FILEITEM\Name), #PB_String) Sort the list into ascending alphabetical order of file name. Line before the comment about showing the list and the So now things should begin to look a bitįinally, for now, the list isn't in any particular order, so let's The FormatDate() function takes a date in PureBasic's own numeric date format andĭisplays it in a format that we can specify. Replace the last three Debug statementsĭebug "Created = " + FormatDate("%dd/%mm/%yyyy", Files()\DateCreated)ĭebug "Accessed = " + FormatDate("%dd/%mm/%yyyy", Files()\DateAccessed)ĭebug "Modified = " + FormatDate("%dd/%mm/%yyyy", Files()\DateModified) So let's make them look a bit more familiar. Ok, firstly, the dates in the output are just numbers - this isn't very helpful, FinishDirectory(0)ĮndIf Shows the results in the debug window (if there is no entry, nothing will be displayed) ForEach Files()ĭebug "Attributes = " + StrU( Files()\Attributes)ĭebug "Created = " + StrU( Files()\DateCreated)ĭebug "Accessed = " + StrU( Files()\DateAccessed)ĭebug "Modified = " + StrU( Files()\DateModified) Files()\Name = DirectoryEntryName(0)įiles()\Attributes = DirectoryEntryAttributes(0)įiles()\DateCreated = DirectoryEntryDate(0, #PB_Date_Created)įiles()\DateAccessed = DirectoryEntryDate(0, #PB_Date_Accessed)įiles()\DateModified = DirectoryEntryDate(0, #PB_Date_Modified)ĮndIf Wend Close the directory. And populate it with the properties of the file. If DirectoryEntryType(0) = #PB_DirectoryEntry_File Add a new element to the list. If the directory entry is a file, not a folder. Loop through until NextDirectoryEntry(0) becomes zero - indicating that there are no more entries. If this is ok, begin enumeration of entries. Result = ExamineDirectory(0, Folder, "*.*") Open the directory to enumerate all its contents. This function gets the home directory for the logged on user. Structure FILEITEMĮndStructure Now we define a new list of files using the structure previously specified and some other working variables we'll use later on. This section describes the fields of a structure or record, mostly integers in this case, but notice the string for the file name and the quad for the file size.

Will come back to this example later on and make it a bit more friendly in several For now the output isn't very exciting but we User's home directory into a structured list. A negative value can be used to subtract a date.This example gathers information about the files in the logged on Will be '30 april 2008', since april does not have 31 days. The numbers of days per month varies, for example: if a month is added to '31 march 2008' the result Note: when #PB_Date_Month is used, it will automatically account for the fact that #PB_Date_Second : Will add 'Value' Seconds to the date #PB_Date_Minute : Will add 'Value' Minutes to the date #PB_Date_Hour : Will add 'Value' Hours to the date Other things are that the cpu has support for 16 bit registers so you don't need the modulo or 'and' operation and the cpu has a rotate opcode (ror) so you can do a rotation of one bit directly instead of combining the results of two shift operations that PureBasic. #PB_Date_Day : Will add 'Value' Days to the date PureBasic uses variables and variables are slower compared to cpu registers.

#PB_Date_Week : Will add 'Value' Weeks to the date #PB_Date_Month : Will add 'Value' Months to the date #PB_Date_Year : Will add 'Value' Years to the date It can be one of the following constants:

The date value to which the value should be added. Date = AddDate(Date, Type, Value) Description
