Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim data() As Byte
Dim sData As String
Dim bc As ByteConverter
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
'data is just an arry for test - you would use live data
data = Array As Byte(0x1B,0x00,0x58,0x1B,0x14,0x59,0x1B,0x02,0x20,0x20,0x33,0x35,0x2E,0x31,0x30,0x1B,0x22,0x20,0x20,0x35,0x2E,0x32,0x32)
sData = bc.StringFromBytes(data,"ascii")
decode(sData)
End Sub
Sub decode(s As String)
Dim cnt As Int = 0
Do While cnt < s.Length
If s.CharAt(cnt) = Chr(0x1b) Then ' look for the esc char
Select s.CharAt(cnt+1) ' get the code for header
Case Chr(0x00)
Log("X available")
cnt = cnt + 3
Case Chr(0x14)
Log("Y available")
cnt = cnt + 3
Case Chr(0x02) ' X value
Log("X value = "&s.SubString2(cnt+2,s.IndexOf2(Chr(0x1b),cnt+2)).Trim)
cnt = cnt + 9
Case Chr(0x22) ' Y value
Log("Y value = "&s.SubString(cnt+2).Trim)
cnt = cnt + 8
End Select
End If
Loop
End Sub