Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Private B4XTable1 As B4XTable
Private const CSVFileName As String = "test.csv"
Private su As StringUtils
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
End Sub
Sub Button1_Click
'this works to 99% always shows the data
Dim header As List
header.Initialize
If File.Exists(File.DirApp, CSVFileName) Then
Dim data As List =su.LoadCSV2(File.DirApp, CSVFileName, ",",header)
End If
For i = 0 To 13
B4XTable1.AddColumn(header.Get(i), B4XTable1.COLUMN_TYPE_TEXT)
Next
B4XTable1.SetData(data)
End Sub
Sub Button2_Click
'this fails all the time
Wait For (GetTestData(mydate,myitem)) Complete (data As List)
B4XTable1.SetData(data)
B4XTable1.RefreshNow
End Sub
Sub GetTestData (date As Object,item As String)
Dim Data As List
Data.Initialize
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand
cmd = CreateCommand("selectItems", Array As Object(date,item))
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone (j As HttpJob)
If j.Success Then
InitTable (0)
req.HandleJobAsync(j, "req")
Wait For (req) req_Result (res As DBResult)
For Each row() As Object In res.Rows
Dim s As String = row(0)
If s.Length=10 Then s=s&"000"
row(0)=s
Data.Add(row)
Next
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
Return Data
End Sub