H Hamied Abou Hulaikah Well-Known Member Licensed User Longtime User Jun 10, 2021 #1 Hi I tried many times/approach to read job.response value and compare it, always failed! Code: Copy HttpJob.Initialize("job1") HttpJob.Download("url") Code: Copy 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 Code: Copy 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 Code: Copy 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?
Hi I tried many times/approach to read job.response value and compare it, always failed! Code: Copy HttpJob.Initialize("job1") HttpJob.Download("url") Code: Copy 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 Code: Copy 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 Code: Copy 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?
tigrot Well-Known Member Licensed User Longtime User Jun 10, 2021 #2 Show job.response value so you can check. Use log(job.response). Upvote 0
H Hamied Abou Hulaikah Well-Known Member Licensed User Longtime User Jun 10, 2021 #3 Job.response log print 1 or 0 no problem The problem when you check if it is 1 or 0 programmatically! Not work!!! Upvote 0
Job.response log print 1 or 0 no problem The problem when you check if it is 1 or 0 programmatically! Not work!!!
tigrot Well-Known Member Licensed User Longtime User Jun 10, 2021 #4 Compare with substring: B4X: Copy Dim bc As ByteConverter Select bc.SubString2(Job.Response, 0, 1) Case "0" Log("0") Case "1" Log("1") End Select Upvote 0
Compare with substring: B4X: Copy Dim bc As ByteConverter Select bc.SubString2(Job.Response, 0, 1) Case "0" Log("0") Case "1" Log("1") End Select
H Hamied Abou Hulaikah Well-Known Member Licensed User Longtime User Jun 11, 2021 #5 tigrot said: Compare with substring: B4X: Copy Dim bc As ByteConverter Select bc.SubString2(Job.Response, 0, 1) Case "0" Log("0") Case "1" Log("1") End Select Click to expand... Not work! Note: The Job.response.length is 1 Upvote 0
tigrot said: Compare with substring: B4X: Copy Dim bc As ByteConverter Select bc.SubString2(Job.Response, 0, 1) Case "0" Log("0") Case "1" Log("1") End Select Click to expand... Not work! Note: The Job.response.length is 1
H Hamied Abou Hulaikah Well-Known Member Licensed User Longtime User Jun 11, 2021 #6 I figured out the problem, it is SELECT statement : simply Select/Case not working in B4R, WHY? any explanation. Code: Copy 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 Code: Copy 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 Upvote 0
I figured out the problem, it is SELECT statement : simply Select/Case not working in B4R, WHY? any explanation. Code: Copy 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 Code: Copy 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
Erel B4X founder Staff member Licensed User Longtime User Jun 13, 2021 #7 You are comparing an array of bytes with a string. These are similar but not identical objects. Try this: Code: Copy Dim bc As ByteConverter Dim s As String = bc.StringFromBytes(Job.Response) Select s Case "0" Log("Aaa") Case "1" Log("!11") End Select Though your working code is better. Upvote 0
You are comparing an array of bytes with a string. These are similar but not identical objects. Try this: Code: Copy Dim bc As ByteConverter Dim s As String = bc.StringFromBytes(Job.Response) Select s Case "0" Log("Aaa") Case "1" Log("!11") End Select Though your working code is better.