Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/FolderItem ItemsSorted
This example is the version from Sun, 15th Jun 2019.
Project "FolderItem ItemsSorted.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
EventHandler Sub Open()
Dim folder As FolderItem = SpecialFolder.Desktop
Dim ItemsSorted() As FolderItem = folder.TrueItemsSorted(False)
Break
End EventHandler
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Module Module1
Function Items(extends f as FolderItem, IncludeInvisible as Boolean = true) As FolderItem()
// return all items in a folder
// resoloves aliases or links
// optionally filters hidden files
Dim items() As FolderItem
Dim c As Integer = f.Count
For i As Integer = 1 To c
Dim item As FolderItem = f.Item(i)
If item <> Nil Then
If IncludeInvisible Or item.Visible Then
items.Append item
end if
End If
Next
Return items
End Function
Function ItemsSorted(extends f as FolderItem, IncludeInvisible as Boolean = true) As FolderItem()
// return all items in a folder ordered by display name
// resoloves aliases or links
// optionally filters hidden files
Dim items() As FolderItem
dim names() As string
Dim c As Integer = f.Count
For i As Integer = 1 To c
Dim item As FolderItem = f.Item(i)
If item <> Nil Then
If IncludeInvisible Or item.Visible Then
items.Append item
names.Append item.DisplayName
end if
End If
Next
names.SortWith items
Return items
End Function
Function TrueItems(extends f as FolderItem, IncludeInvisible as Boolean = true) As FolderItem()
// return all true items in a folder
// does not resolove aliases or links
// optionally filters hidden files
Dim items() As FolderItem
Dim c As Integer = f.Count
For i As Integer = 1 To c
Dim item As FolderItem = f.TrueItem(i)
if item <> nil then
If IncludeInvisible Or item.Visible Then
items.Append item
end if
end if
Next
Return items
End Function
Function TrueItemsSorted(extends f as FolderItem, IncludeInvisible as Boolean = true) As FolderItem()
// return all true items in a folder ordered by display name
// does not resolove aliases or links
// optionally filters hidden files
Dim items() As FolderItem
dim names() As string
Dim c As Integer = f.Count
For i As Integer = 1 To c
Dim item As FolderItem = f.TrueItem(i)
If item <> Nil Then
If IncludeInvisible Or item.Visible Then
items.Append item
names.Append item.DisplayName
end if
End If
Next
names.SortWith items
Return items
End Function
End Module
End Project
The items on this page are in the following plugins: MBS Util Plugin.