Sub btn1_Clicked(Target As String)
page.Pause
Dim shl As Shell
shl.Initialize("shl", "python", Array As String("myscript.py"))
shl.WorkingDirectory = "/home/pi/B4J/Reader"
shl.Run(30000)
End Sub
Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
If Success And ExitCode = 0 Then
Log("Success")
Log(StdOut)
Dim list3 As ABMList = page.Component("list3")
list3.Clear
Dim lbl As ABMLabel = page.Component("lbl")
lbl.Text = ""
Dim sp() As String = Regex.Split("\n", StdOut)
For i = 0 To sp.Length-1
Select Case True
Case sp(i).StartsWith("SERIAL:")
i = i + 1
lbl.Text = "Scanner: " & sp(i).SubString2(sp(i).Length-6,sp(i).Length)
Case sp(i).StartsWith("BARCODES")
i = i + 1
Do While Not(sp(i).StartsWith("DONE"))
list3.AddItem("list" & i, BuildSimpleItem("lbl" & i, sp(i)))
i = i + 1
Loop
End Select
Next
Log("done")
lbl.Refresh
list3.Refresh
myToastId = myToastId + 1
page.ShowToast("toast" & myToastId, "toastgreen", "De scanner is uitgelezen", 5000)
list3.refresh
Else
Log("Error: " & StdErr)
myToastId = myToastId + 1
page.ShowToast("toast" & myToastId, "toastred", "De scanner is niet uitgelezen", 5000)
list3.refresh
End If
page.Resume
End Sub