Android Question Error Description: Syntax error

Isac

Active Member
Licensed User
Longtime User
Hi everyone,

I have error on this line,
I don't understand how to fix

Thank you



B4A version: 12.20
Code analysis. Mistake
Program parsing error.
Error Description: Syntax error.
Line error: 71 (main)
If Not OnResult.Success Then


B4X:
Sub Result(OnResult As OkHttpResponse)
    ProgressDialogHide
    If Not OnResult.Success Then     <---------------------------------------------------- error
        ToastMessageShow("Error: "&OnResult.ErrorMessage, True) <--------------------------error
    End If  <--------------------------------------------------------------------------------------error
   
    Dim xml As XmlLayoutBuilder
    xml.InitializeFromString(OnResult.GetString("UTF8"))
    Dim items As List = xml.GetItems("Item")
    ListView1.Clear
    For Each item As Map In items
        Dim attributes As Map = item.Get("ItemAttributes")
        ListView1.AddSingleLine(attributes.Get("Title"))
    Next
End Sub
 

Attachments

  • riga.PNG
    riga.PNG
    20.1 KB · Views: 43

drgottjr

Expert
Licensed User
Longtime User
If Not (OnResult.Success) Then
see below. success is a property of httpjob not okhttresponse
so, assuming dim onresult as httpjob, you could say if not(onresult.success).
 
Last edited:
Upvote 0

Isac

Active Member
Licensed User
Longtime User
If Not (OnResult.Success) Then
B4A Version: 12.20
Code analysis. (0.01 seconds)
Java Version: 11
Building the folder structure. (0.01 seconds)
Compiling the code. Mistake
Error compiling the program.
Error Description: Unknown Member: Success
Line error: 71
If not (OnResult.Success) Then
Word: success

B4X:
If Not (OnResult.Success) Then
        ToastMessageShow("Error: "&OnResult.ErrorMessage, True)
    End If
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
sorry, it's httpjob.success. okhttpresponse has a different set of properties.

normally, the convention is:
B4X:
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://www.google.com")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
   Log(j.GetString)
End If
j.Release
 
Upvote 0
Top