Android Question Job.GetString Cast - Problem

WebQuest

Active Member
Licensed User
Hello community,
Merry Christmas to all!
I am struggling with not being able to list the result of job.GetString. Job.GetString drops the values as a single string like so:
214545437421454214374374534534534694694694. I am using DbUtils in a B4j server and I use ExecuteList via the Handle to receive data on a b4a app. But the way to add them to a separate list escapes me. I appreciate any example ...
 

drgottjr

Expert
Licensed User
Longtime User
Job.GetString drops the values as a single string like so:
that's what it's supposed to do. maybe you should show your code. just the b4a part.
 
Upvote 0

WebQuest

Active Member
Licensed User
Hi, the working code is just that I get all the elements from the b4j server as a single string. I need to receive separate data. The function reads the rows of a column from a Sqlite db.

B4J Server:
'Class module
Sub Class_Globals
    
End Sub

Public Sub Initialize

End Sub

Public Sub Handle(req As ServletRequest, resp As ServletResponse)
    Dim lista As List
    lista.Initialize
  
    lista.Add(DBUtils.ExecuteList(Main.SQL1, "SELECT Cell FROM Tab", Null,0,lista))
    Log(lista)
    resp.Write(lista.Get(i))
End Sub

B4a Client:
Sub JobDone(j As HttpJob)
    If j.Success Then
        If j.JobName = "send object" Then
            Log(j.GetString)
        Else If j.JobName = "FunctionPulsanti" Then
            Log(j.GetString) 'this: Log=2145454394394467467467'
        End If
    Else
        Log("Error: " & j.ErrorMessage)
        Msgbox(j.ErrorMessage, "Error")
    End If
    j.Release
    ProgressDialogHide
End Sub
 
Upvote 0

WebQuest

Active Member
Licensed User
Hi Erel,
(i) was not in use I did not darken it.
I am trying to submit 15 records of a column. I use DbUtils ver.2.11, and ExecuteJsone does not appear. I had already thought about creating a jsone map but I don't know where to start. So far I have implemented functions with mySql with php files on real servers. I'm not familiar with a b4j server. I followed your example to create the server but in the example you send data with EcecuteHtml.
 
Upvote 0

WebQuest

Active Member
Licensed User
Hi Erel,
I solved my problem! :)
I modified the DBUtils module and added a comma separator. Then I did a Split.

Added comma separator in DbUtils ExecuteList:
'Executes the query and fills the list with the values in the first column.
Public Sub ExecuteList(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, List1 As List)
    List1.Clear
    Dim Table As List
    Table = ExecuteMemoryTable(SQL, Query, StringArgs, Limit)
    If Table.Size = 0 Then Return
    Dim Cols() As String
    For i = 0 To Table.Size - 1
        Cols = Table.Get(i)
        List1.Add(","&Cols(0)) 'Add ,
    Next
End Sub

Split execution in b4a:
Sub JobDone(j As HttpJob)
    If j.Success Then
        If j.JobName = "send object" Then
            Log(j.GetString)
        Else If j.JobName = "FunctionPulsanti" Then
              Log(j.GetString) 'Now the received string is divided with the comma = 54,214, ....
        Dim numbers() As String
            numbers = Regex.Split(",", j.GetString)
            Dim l As List
            l.Initialize2(numbers) 'Adding individual items to the list
            Log(l)
            
    Else
        Log("Error1: " & j.ErrorMessage)
        'Msgbox(j.ErrorMessage, "Error1")
    End If
    j.Release
    ProgressDialogHide
End Sub
 
Upvote 0
Top