Platforms to show: All Mac Windows Linux Cross-Platform

/Dongle/Matrix Dongle
Function:
Required plugins for this example: MBS Dongle Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Dongle/Matrix Dongle
This example is the version from Sun, 17th Mar 2012.
Project "Matrix Dongle.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Close() call MatrixDongleMBS.ReleaseMatrixAPI End EventHandler
EventHandler Sub Open() dim err as integer err=MatrixDongleMBS.InitMatrixAPI if err<>0 then MsgBox "Error on initializing: "+str(Err) quit end if End EventHandler
End Class
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() search End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control tFound Inherits Label
ControlInstance tFound Inherits Label
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub Change() updateButton End EventHandler
End Control
Control out Inherits Listbox
ControlInstance out Inherits Listbox
EventHandler Sub Open() me.ColumnAlignment(1)=me.AlignRight me.ColumnAlignment(2)=me.AlignRight End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() readvalues End EventHandler
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
EventHandler Sub TextChange() updateButton End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() writevalue readvalues End EventHandler
End Control
EventHandler Sub Open() search End EventHandler
Sub readvalues() dim port,nr,size as integer out.DeleteAllRows port=list.CellTag(list.ListIndex,0) nr=list.CellTag(list.ListIndex,1) size=MatrixDongleMBS.DongleMemSize(nr, port) if size<=0 then MsgBox "No bytes on the dongle!?" Return end if dim m as MemoryBlock = NewMemoryBlock(size) dim i as integer dim count as integer = size/4 dim usercode as integer = val(EditField1.text) dim result as integer result=MatrixDongleMBS.DongleReadData(usercode, m, count, nr, port) if result<count then MsgBox "Error: "+str(result) end if for i=0 to count-1 out.AddRow str(i) out.Cell(out.LastIndex,1)=hex(m.Long(i*4)) out.Cell(out.LastIndex,2)=str(m.Long(i*4)) next End Sub
Sub search() dim result as integer list.DeleteAllRows result=MatrixDongleMBS.DongleFind Select case result case 85 tFound.text="USB" case 0 tFound.text="none" case 1 tFound.text="LPT 1" case 2 tFound.text="LPT 2" case 3 tFound.text="LPT 3" else MsgBox "Err: "+str(result) end Select for i as integer=0 to 3 dim port as integer=i dim ports as string if i=0 then ports="USB" port=85 else ports="LPT"+str(i) end if // --- Get the count of dongles on 'DNG_Port' --- dim count as integer = MatrixDongleMBS.DongleCount(port) if Count <= 0 then continue //--- Search the dongle with correct UserCode, if ---*/ //--- there are more than one dongles present. ---*/ for Nr as integer = 1 to count // dim SerNr as integer = Dongle_ReadSerNr(UserCode, DNG_Nr, DNG_Port); list.addrow ports list.CellTag(list.LastIndex,0)=port list.CellTag(list.LastIndex,1)=nr result=MatrixDongleMBS.DongleMemSize(nr, port) if result>1 then list.cell(list.LastIndex,1)=str(result)+" Byte" else list.cell(list.LastIndex,1)="Error: "+str(result) end if result=MatrixDongleMBS.DongleModel(nr, port) if result>1 then list.cell(list.LastIndex,2)=str(result) else list.cell(list.LastIndex,2)="Error: "+str(result) end if result=MatrixDongleMBS.DongleVersion(nr, port) if result>1 then list.cell(list.LastIndex,3)=str(result\65536)+"."+str(result mod 65536) else list.cell(list.LastIndex,3)="Error: "+str(result) end if next next End Sub
Sub updateButton() if list.ListIndex<0 and EditField1.text<>"" then PushButton2.Enabled=false PushButton3.Enabled=false else PushButton2.Enabled=true PushButton3.Enabled=true end if End Sub
Sub writevalue() dim port,nr,size as integer port=list.CellTag(list.ListIndex,0) nr=list.CellTag(list.ListIndex,1) size=MatrixDongleMBS.DongleMemSize(nr, port) if size<=0 then MsgBox "No bytes on the dongle!?" Return end if // read old values dim m as MemoryBlock = NewMemoryBlock(size) dim i as integer dim count as integer = size/4 dim usercode as integer = val(EditField1.text) dim result as integer result=MatrixDongleMBS.DongleReadData(usercode, m, count, nr, port) if result<count then MsgBox "Read Error: "+str(result) end if // increase first value in memoryblock m.Long(0)=m.Long(0)+1 // write back result=MatrixDongleMBS.DongleWriteData(usercode, m, count, nr, port) if result<count then MsgBox "Write Error: "+str(result) end if End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

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


💬 Ask a question or report a problem
The biggest plugin in space...