« ZUGFeRD 2.0 and Factu… | Home | MBS Plugins @ XDC 201… »

Tip of the day: Folderitem items sorted


Here are some code snippets for methods, you may want to put in a module and use in your project. They return you the items or true items in a folder sorted by name and optionally with hidden items skipped:

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
15 06 19 - 18:28