Sub Class_Globals
Private Root As B4XView
Private xui As XUI
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
' --- Create a @D JSON array with listname and a Case number field
' --- for reference because JSON writes the array in random order.
' --- Used fieldnames:
' --- List: Any name you want and more then one listname is possible
' --- Case: Array index number
' --- Action: Any description what to do
' --- Bitmap: any bitname file you want
Dim JsonStr As String = $"
[
[
"List",
"Case",
"Action",
"Bitmap"
],
[
"myList1",
1,
"This is action 1",
"1.bmp"
],
[
"myList1",
2,
"This is action 2",
"2.bmp"
],
[
"myList1",
3,
"This is action 3",
"3.bmp"
],
[
"myList1",
4,
"This is action 4",
"4.bmp"
],
[
"myList1",
5,
"This is action 5",
"5.bmp"
],
[
"myList1",
6,
"This is action 6",
"6.bmp"
],
[
"myList1",
7,
"This is action 7",
"7.bmp"
],
[
"myList1",
8,
"This is action 8",
"8.bmp"
]
]
"$
' --- Past the JsonStr on http://basic4ppc.com:51042/json/index.html and twink the given result code to
Dim parser As JSONParser
parser.Initialize(JsonStr)
Dim jRoot As List = parser.NextArray
Dim n As Int = 0
For Each coljRoot As List In jRoot
Dim X1 As Int = 0
For Each colcoljRoot As String In coljRoot
X1 = X1 + 1
Select n
' --- Select an action number between 1 to 8 from example
Case 8
Select X1
' --- Third field is the action to take
Case 3
' --- Show the action to take
Log($"Action: ${colcoljRoot}"$)
Dim MsgStr As String = colcoljRoot
End Select
End Select
' --- Log all values
' Log(colcoljRoot)
Next
n = n + 1
Next
' --- Show the result
xui.MsgboxAsync(MsgStr, "Action to take")
End Sub