Platforms to show: All Mac Windows Linux Cross-Platform

/Util/WriteFileMBS test


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/WriteFileMBS test

This example is the version from Sat, 3rd May 2019.

Project "WriteFileMBS test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() #Pragma DisableBackgroundTasks Dim intMaxLines As Integer = Val(TextField1.Text) Dim intMaxFile As Integer = Val(TextField2.Text) ' create test string Dim strTest(-1) As String For i As Integer = 1 To intMaxLines strTest.Append "x" Next Dim strAll As String = Join(strTest,"") Dim inStrData As String Dim fDir As FolderItem Dim t As Double fDir = SpecialFolder.Desktop.Child("WriteFile Xojo TextStreams") fDir.CreateAsFolder ' create for Xojo t = Microseconds For i As Integer = 1 To intMaxFile Dim fFile As FolderItem = fDir.Child("test-" + Str(i) + ".txt") Dim b As TextOutputStream = TextOutputStream.Create(fFile) b.Write strAll b.Close Next t = Microseconds - t List.AddRow "TextOutputStream write", Str(t / 1000.0, "0.0") ' read in for Xojo t = Microseconds For i As Integer = 1 To intMaxFile Dim fFile As FolderItem = fDir.Child("test-" + Str(i) + ".txt") Dim tIn As TextInputStream = TextInputStream.Open(fFile) inStrData = tIn.ReadAll If LenB(inStrData) <> Len(strAll) Then Break end if tIn.Close Next t = Microseconds - t List.AddRow "TextInputStream read", Str(t / 1000.0, "0.0") // BinaryStream fDir = SpecialFolder.Desktop.Child("WriteFile Xojo BinaryStream") fDir.CreateAsFolder ' create for Xojo t = Microseconds For i As Integer = 1 To intMaxFile Dim fFile As FolderItem = fDir.Child("test-" + Str(i) + ".txt") Dim b As BinaryStream = BinaryStream.Create(fFile, True) b.Write strAll b.Close Next t = Microseconds - t List.AddRow "BinaryStream write", Str(t / 1000.0, "0.0") ' read in for Xojo t = Microseconds For i As Integer = 1 To intMaxFile Dim fFile As FolderItem = fDir.Child("test-" + Str(i) + ".txt") Dim tIn As BinaryStream = BinaryStream.Open(fFile) inStrData = tIn.Read(tin.Length) If LenB(inStrData) <> Len(strAll) Then Break End If tIn.Close Next t = Microseconds - t List.AddRow "BinaryStream read", Str(t / 1000.0, "0.0") // MBS Stuff fDir = SpecialFolder.Desktop.Child("WriteFile MBS") fDir.CreateAsFolder t = Microseconds ' create for MBS For i As Integer = 1 To intMaxFile Dim fFile As FolderItem = fDir.Child("test-" + Str(i) + ".txt") if not fFile.WriteFileMBS(strAll) then Break end if next t = Microseconds - t List.AddRow "MBS Write", Str(t / 1000.0, "0.0") ' Write for MBS t = Microseconds dim s as String For i As Integer = 1 To intMaxFile Dim fFile As FolderItem = fDir.Child("test-" + Str(i) + ".txt") If Not fFile.ReadFileMBS(s) Then Break end if next t = Microseconds - t List.AddRow "MBS Read", Str(t / 1000.0, "0.0") End EventHandler
End Control
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
Control TextField2 Inherits TextField
ControlInstance TextField2 Inherits TextField
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control Label5 Inherits Label
ControlInstance Label5 Inherits Label
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub Open() me.ColumnAlignment(1) = me.AlignRight End EventHandler
End Control
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
End Project

The items on this page are in the following plugins: MBS Util Plugin.


The biggest plugin in space...