B4R Question Reading Job.Response value

HAH

Well-Known Member
Licensed User
Hi
I tried many times/approach to read job.response value and compare it, always failed!

Request url that response with 0 or 1 only without any space:
 HttpJob.Initialize("job1")
 HttpJob.Download("url")
Comparison inside select Not work:
Sub JobDone (Job As JobResult)
    If Job.Success Then
        If Job.JobName="job1" Then
            'always job.response=1 or 0
            Select Job.Response
                Case "0".GetBytes
                    Log("0")
                Case "1".GetBytes
                    Log("1")
            End Select
        End If
    End If
End Sub
Comparison inside select Not work:
Sub JobDone (Job As JobResult)
    If Job.Success Then
        If Job.JobName="job1" Then
            'always job.response=1 or 0
            Select Job.Response
                Case "0"
                    Log("0")
                Case "1"
                    Log("1")
            End Select
        End If
    End If
End Sub
Comparison inside select Not work:
Sub JobDone (Job As JobResult)
    If Job.Success Then
        If Job.JobName="job1" Then
            'always job.response=1 or 0
            Select Job.Response
                Case 0
                    Log("0")
                Case 1
                    Log("1")
            End Select
        End If
    End If
End Sub
What is the wrong?
 

HAH

Well-Known Member
Licensed User
Job.response log print 1 or 0 no problem
The problem when you check if it is 1 or 0 programmatically! Not work!!!
 

HAH

Well-Known Member
Licensed User
Compare with substring:
B4X:
            Dim bc As ByteConverter
            Select bc.SubString2(Job.Response, 0, 1)
                Case "0"
                    Log("0")
                Case "1"
                    Log("1")
            End Select
Not work!
Note: The Job.response.length is 1
 

HAH

Well-Known Member
Licensed User
I figured out the problem, it is SELECT statement : simply Select/Case not working in B4R, WHY? any explanation.
Working:
Sub JobDone (Job As JobResult)
    If Job.Success Then
        If Job.JobName="job1" Then
            'always job.response=1 or 0
            if Job.Response="0" Then Log("0")
            if Job.Response="1" Then log("1")
        End If
    End If
End Sub
Not working using Select/Case:
Sub JobDone (Job As JobResult)
    If Job.Success Then
        If Job.JobName="job1" Then
            'always job.response=1 or 0
            Select Job.Response
                Case "0"
                    Log("0")
                Case "1"
                    Log("1")
            End Select
        End If
    End If
End Sub
 
Top