Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/FileList/FileList
This example is the version from Sun, 22th Feb 2020.
Project "FileList.xojo_binary_project"
Class MainWindow Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub Change()
dim s as string
if me.ListIndex=-1 then
Title=""
else
s=me.Cell(me.ListIndex,0)
Title=s+" "+str(len(s))+" "+str(lenb(s))
end if
End EventHandler
EventHandler Sub DoubleClick()
dim i as integer
i=me.Celltag(me.ListIndex,0)
f.item(i).Launch
Exception
End EventHandler
End Control
Control CheckSkipFiles Inherits CheckBox
ControlInstance CheckSkipFiles Inherits CheckBox
EventHandler Sub Action()
run
End EventHandler
End Control
Control CheckSkipFolders Inherits CheckBox
ControlInstance CheckSkipFolders Inherits CheckBox
EventHandler Sub Action()
run
End EventHandler
End Control
Control CheckSkipHiddenFiles Inherits CheckBox
ControlInstance CheckSkipHiddenFiles Inherits CheckBox
EventHandler Sub Action()
run
End EventHandler
End Control
Control CheckSkipHiddenFolders Inherits CheckBox
ControlInstance CheckSkipHiddenFolders Inherits CheckBox
EventHandler Sub Action()
run
End EventHandler
End Control
EventHandler Sub Open()
MakeTestFile // Make a test file to test unicode
run
End EventHandler
Function Fix(s as string) As string
dim i,c as integer
dim z,t as string
// removes non printable characters
c=len(s)
for i=1 to c
z=mid(s,i,1)
if asc(z)<32 then
t=T+" "
else
t=T+z
end if
next
Return t
End Function
Protected Sub MakeTestFile()
// create a test file with a special unicode file name
Dim s As String = "ƋƋƴNJƮƏ.txt"
Dim f As FolderItem = SpecialFolder.Desktop.Child(s)
If f <> Nil Then
Dim t As TextOutputStream = f.CreateTextFile
If t <> Nil Then
t.Write "Hello"
End If
End If
End Sub
Private Sub run()
Dim list As listbox = Self.List
list.DeleteAllRows
Dim SkipMode As Integer
If CheckSkipFiles.Value Then
SkipMode = BitwiseOr(SkipMode, FileListMBS.SkipFiles)
end if
If CheckSkipFolders.Value Then
SkipMode = BitwiseOr(SkipMode, FileListMBS.SkipFolders)
End If
If CheckSkipHiddenFiles.Value Then
SkipMode = BitwiseOr(SkipMode, FileListMBS.SkipHiddenFiles)
End If
If CheckSkipHiddenFolders.Value Then
SkipMode = BitwiseOr(SkipMode, FileListMBS.SkipHiddenFolders)
End If
f = New FileListMBS(SpecialFolder.Desktop, "", SkipMode)
Dim c As Integer = f.Count
Title=Str(c)+" items on the desktop"
c=c-1
For i As Integer = 0 To c
Dim s As String = f.Name(i)
List.AddRow s'+" "+str(len(s))+" "+str(lenb(s))
If Not f.Directory(i) Then
List.Cell(List.LastIndex,1)=Format((f.PhysicalDataLength(i)+f.PhysicalResourceLength(i))/1024,"0")+" KB"
End If
If f.Visible(i) Then
s="visible"
Else
s="invisible"
End If
If f.Directory(i) Then
s=s+", directory"
End If
List.Cell(List.LastIndex,2)=s
Dim d As date = f.ModificationDate(i, False)
If d = Nil Then
List.Cell(List.LastIndex,3)="?"
Else
List.Cell(List.LastIndex,3)=d.ShortDate+" "+d.ShortTime
End If
d=New date
d=f.CreationDate(i, False)
If d = Nil Then
List.Cell(List.LastIndex,4)="?"
Else
List.Cell(List.LastIndex,4)=d.ShortDate+" "+d.ShortTime
End If
d=f.LastAccessDate(i, False)
If d = Nil Then
List.Cell(List.LastIndex,5)="?"
Else
List.Cell(List.LastIndex,5)=d.ShortDate+" "+d.ShortTime
End If
s=Fix(f.Type(i))+"/"+Fix(f.Creator(i))
If s<>"/" Then
List.Cell(List.LastIndex,6)=s
End If
List.Cell(List.LastIndex,7)=Hex(f.NodeID(i))
List.Cell(List.LastIndex,8)=Str(f.IsHardLinked(i))
List.Celltag(List.LastIndex,0)=i // for double click
Next
End Sub
Property Protected base As double
Property Protected f As FileListMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu7 = ""
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu6 = ""
MenuItem UntitledMenu5 = ""
MenuItem UntitledMenu4 = ""
End MenuBar
Class App Inherits Application
EventHandler Function UnhandledException(error As RuntimeException) As Boolean
MsgBox Introspection.GetType(error).fullname+EndOfLine+EndOfLine+error.Message+EndOfLine+Join(error.Stack, EndOfLine)
Return True
End EventHandler
End Class
End Project
See also:
The items on this page are in the following plugins: MBS Util Plugin.