Example: /DataTypes/HexDump

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/DataTypes/HexDump


Required plugins for this example: MBS Util Plugin, MBS DataTypes Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DataTypes/HexDump

This example is the version from Sat, 19th Jul 2013.

Project "HexDump.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control efShowData Inherits TextArea
ControlInstance efShowData Inherits TextArea
EventHandler Sub Open() me.text = "" End EventHandler
EventHandler Sub TextChange() me.ScrollPosition = 0 End EventHandler
End Control
Control pbDump Inherits PushButton
ControlInstance pbDump Inherits PushButton
EventHandler Sub Action() Dim f As FolderItem Dim b As BinaryStream Dim n As Integer Dim mb As MemoryBlock // open the included gif file to display in hex dump format f = GetOpenFolderItem("") if f <> nil and f.exists then b = f.OpenAsBinaryFile if b <> nil then n = f.Length stSize.Text = Format(n, "#,###") + " bytes" mb = NewMemoryBlock(n) mb.StringValue(0,n) = b.Read(n) b.close HexOut mb else Beep MsgBox "Unable to open thumbsup.gif file as a binarystream" end if end if End EventHandler
End Control
Control stSize Inherits Label
ControlInstance stSize Inherits Label
EventHandler Sub Open() me.text = "" End EventHandler
End Control
EventHandler Sub Open() self.top =50 self.Left = (Screen(0).AvailableWidth - self.Width)/2 End EventHandler
Sub HexOut(mb As MemoryBlock) // This method is passed a memoryblock containing the data to be // displayed. The method formats the data, 16 bytes at a time in a hex // dump format. Three MBS features are used: // StringHandleMBS for fast string building, HexstringMBS to format // the 16 bytes in hex with spacing, and ReplaceNonPrintableCharactersMBS // to format the 16 bytes to the right of the hex display showing the printable // characters. Dim i, j, k, ln, m, n, pos As Integer Dim ltrs(15), s, theHex, theLtrs, thePos As String Dim r As StringHandleMBS r = new StringHandleMBS n = mb.Size - 1 // number of bytes in memoryblock pos = 0 k = 16 for i = 0 to n step 16 // walk through memoryblock 16 bytes at a time thePos = right("00000" + hex(i), 6) + ": " // format offset part of string ****** if i + 16 > n then k = n - i + 1 // walking past end of memoryblock? s = mb.StringValue(i, k) // get up to 16 bytes from memoryblock as a string theHex = HexstringMBS(s, 2, 16, "", "", " ", " ") // get hex version of string ****** theLtrs = ReplaceNonPrintableCharactersMBS(s) // get character representation ***** //s = thePos + theHex + " " + theLtrs + gcr r.Add thePos + theHex + " " + theLtrs + EndOfLine //efShowData.AppendText s // append to editfield ln = ln + 1 if ln = 16 then // output a blank line after every 16th printed line r.Add " " + EndOfLine //efShowData.AppendText " " + gcr ln = 0 end if Next i efShowData.Text = r.copy End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

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


💬 Ask a question or report a problem