Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Util/Stream Test
Function:
Required plugins for this example: MBS MacOSX Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Stream Test
This example is the version from Mon, 22th Nov 2015.
Project "Stream Test.rbp"
FileTypes
Filetype special/any
End FileTypes
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() file=GetOpenFolderItem("special/any") if file<>nil then filepath.text=file.UnixpathMBS // needs MacOSX Plugin end if End EventHandler
End Control
Control filepath Inherits Label
ControlInstance filepath Inherits Label
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() runBinaryStream End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() runLargebinarystream End EventHandler
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action() runRamStream1 End EventHandler
End Control
Control TBinarystream Inherits Label
ControlInstance TBinarystream Inherits Label
End Control
Control tLargeBinaryStream Inherits Label
ControlInstance tLargeBinaryStream Inherits Label
End Control
Control tramstream1 Inherits Label
ControlInstance tramstream1 Inherits Label
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control PushButton5 Inherits PushButton
ControlInstance PushButton5 Inherits PushButton
EventHandler Sub Action() runRamStream2 End EventHandler
End Control
Control tramstream2 Inherits Label
ControlInstance tramstream2 Inherits Label
End Control
EventHandler Sub Open() file=app.ApplicationFileMBS filepath.text=file.UnixpathMBS Exception End EventHandler
Sub runBinaryStream() dim s as string dim b as BinaryStream dim n,c as integer n=0 b=file.OpenAsBinaryFile(false) if b=nil then MsgBox "Failed to open your target file." else while not b.eof s=b.Read(1000000) c=c+lenb(s) n=CRC_32OfStrContMBS(s,n) wend end if TBinarystream.Text="CRC: "+hex(n)+", "+Format(c,"0")+" Bytes." End Sub
Sub runLargebinarystream() dim s as string dim b as LargeBinaryStreamMBS dim c,n as integer n=0 b=file.OpenAsLargeBinaryStreamMBS(false) if b=nil then MsgBox "Failed to open your target file." else while not b.eof s=b.Read(1000000) c=c+lenb(s) n=CRC_32OfStrContMBS(s,n) wend end if tLargeBinaryStream.Text="CRC: "+hex(n)+", "+Format(c,"0")+" Bytes." End Sub
Sub runRamStream1() dim s as string dim b as BinaryStream dim n,c as integer dim r as RamStreamMBS b=file.OpenAsBinaryFile(false) if b=nil then MsgBox "Failed to open your target file." else r=CreateRamStreamMBS(1000000) while not b.eof s=b.Read(1000000) r.Write s wend r.Position=0 c=0 n=0 while not r.eof s=r.Read(1000000) c=c+lenb(s) n=CRC_32OfStrContMBS(s,n) wend end if tramstream1.Text="CRC: "+hex(n)+", "+Format(c,"0")+" Bytes." End Sub
Sub runRamStream2() dim s as string dim b as LargeBinaryStreamMBS dim n,c as integer dim r as RamStreamMBS b=file.OpenAsLargeBinaryStreamMBS(false) if b=nil then MsgBox "Failed to open your target file." else r=CreateRamStreamMBS(1000000) while not b.eof s=b.Read(1000000) r.Write s wend r.Position=0 c=0 n=0 while not r.eof s=r.Read(1000000) c=c+lenb(s) n=CRC_32OfStrContMBS(s,n) wend end if tramstream2.Text="CRC: "+hex(n)+", "+Format(c,"0")+" Bytes." End Sub
Property Protected file As folderitem
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

Feedback, Comments & Corrections

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





Links
MBS FileMaker Plugins