Android Question Array expected appears in log

ianvirgo74

New Member
Hello All,
this is my program code
{code}
Dim ServerData As List
ServerData.Initialize
Wait For (GetDataFromJRDC()) Complete (ServerData As List)
Log("Data from server successfully retrieved:" & ServerData.Size)
For Each mData As Map In ServerData
Log("Username: " & mData.Get("username") & ", Last edit: " & mData.Get("last_edit"))
Next

Private Sub GetDataFromJRDC() As ResumableSub
Dim DataServer As List
DataServer.Initialize

Wait For (B4XPages.MainPage.jRDC.GetRecord("get_loginsync", Null)) Complete (Answer As Map)
If Answer.Get("Success") Then
Dim l As List
Dim rs As DBResult
rs = Answer.Get("Data")
l = rs. Rows
If l.Size > 0 Then
For Each row() As Object In l
Dim mData As Map
mData.Initialize
mData.Put("username", row(rs.Columns.Get("username")))
mData.Put("last_edit", row(rs.Columns.Get("last_edit")))
DataServer.Add(mData)
Next
End If
Otherwise
MsgboxAsync("An error occurred while connecting to the server: " & Answer.Get("Error"), "Failed")
End If

Return DataServer
End Sub
{/code}

So my question is, why does array expected appear in the logs?
even though when I compile, the program runs correctly without error and I can get the list of data I need
in the logs the expected array will appear when I write the code :Wait For (GetDataFromJRDC()) Complete (ServerData As List)

Is there @anyone who can help me? :)
 

Attachments

  • Log.jpg
    Log.jpg
    7.3 KB · Views: 41
Solution
Change this:
B4X:
Wait For (GetDataFromJRDC()) Complete (ServerData As List)

To this (remove the "()" from the call):
B4X:
Wait For (GetDataFromJRDC) Complete (ServerData As List)

emexes

Expert
Licensed User
If you click on the red error message, the IDE should move the source edit cursor onto the problem line.

The problem might be the "Otherwise" on line 28 below,, which I'm guessing should be "Else":

B4X:
Dim ServerData As List
ServerData.Initialize
Wait For (GetDataFromJRDC()) Complete (ServerData As List)
Log("Data from server successfully retrieved:" & ServerData.Size)
For Each mData As Map In ServerData
    Log("Username: " & mData.Get("username") & ", Last edit: " & mData.Get("last_edit"))
Next

Private Sub GetDataFromJRDC() As ResumableSub
    Dim DataServer As List
    DataServer.Initialize

    Wait For (B4XPages.MainPage.jRDC.GetRecord("get_loginsync", Null)) Complete (Answer As Map)
    If Answer.Get("Success") Then
        Dim l As List
        Dim rs As DBResult
        rs = Answer.Get("Data")
        l = rs. Rows
        If l.Size > 0 Then
            For Each row() As Object In l
                Dim mData As Map
                mData.Initialize
                mData.Put("username", row(rs.Columns.Get("username")))
                mData.Put("last_edit", row(rs.Columns.Get("last_edit")))
                DataServer.Add(mData)
            Next
        End If
    Otherwise
        MsgboxAsync("An error occurred while connecting to the server: " & Answer.Get("Error"), "Failed")
    End If
    Return DataServer
End Sub
 
Upvote 0

ianvirgo74

New Member
I apologize, maybe there was a mistake when I copied my program code, actually otherwise is not included in the coding. This is the correct program code

B4X:
Dim ServerData As List
ServerData.Initialize
Wait For (GetDataFromJRDC()) Complete (ServerData As List)
Log("Data from server successfully retrieved:" & ServerData.Size)
For Each mData As Map In ServerData
    Log("Username: " & mData.Get("username") & ", Last edit: " & mData.Get("last_edit"))
Next

Private Sub GetDataFromJRDC() As ResumableSub
    Dim DataServer As List
    DataServer.Initialize
    DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
    Wait For (B4XPages.MainPage.jRDC.GetRecord("get_loginsync", Null)) Complete (Answer As Map)
    If Answer.Get("Success") Then
        Dim l As List
        Dim rs As DBResult
        rs = Answer.Get("Data")
        l = rs.Rows
        If l.Size > 0 Then
            For Each row() As Object In l
                Dim mData As Map
                mData.Initialize
                mData.Put("username", row(rs.Columns.Get("username")))
                mData.Put("last_edit", DateTime.Date(row(rs.Columns.Get("last_edit"))))
                DataServer.Add(mData)
            Next
        End If
    Else
        MsgboxAsync("An error occurred while connecting to the server: " & Answer.Get("Error"), "Failed")
    End If

    Return DataServer
End Sub
 
Upvote 0

emexes

Expert
Licensed User
This is the correct program code
🍻


If you click on the red error message, the IDE should move the source edit cursor onto the problem line.
What was the result of doing this? It should get you within a line of the problem. If you can't see problem - and we've all sometimes missed seeing the obvious when in the heat of programming battle - then post the three lines before and after the line that the cursor is moved to when you click on the red warning message, ie seven lines altogether.
 
Upvote 1

ianvirgo74

New Member
What was the result of doing this? It should get you within a line of the problem. If you can't see problem - and we've all sometimes missed seeing the obvious when in the heat of programming battle - then post the three lines before and after the line that the cursor is moved to when you click on the red warning message, ie seven lines altogether.
Thank you @emexes for your attention and help, your input is very valuable to me.
 
Upvote 0
Top