Android Question [Solved]Order Poststring

Amateurtje

Member
Licensed User
Longtime User
Hello,

I am looping a posstring to put info in a online db. I got it to work finally but I can not seem to put it in the correct order in the db, which is actually important to me that it gets a correct ascending ID...

The data is in a kvs and is in a correct order. I had to put dim job2 and job initialise into the loop, otherwise it only exectuted the last poststring.... This is probably also not nice but it worked like this and I could not find here a better solution for that....

Like you see in the code, I also tried to reverse the post statements but this did not help (strange)...

I was looking for a job.execute or something but I could not find it..

my code:
Poststring code:
    Dim name As String = "Name1"
    Dim Meetplaats As Int =12''= waardecheck(txtProefNum)

    For i=0 To Starter.kvs.ListKeys.Size-1
        ''    For  i=Starter.kvs.ListKeys.Size-1 To 0 Step -1
        Dim job2 As HttpJob
        job2.Initialize("Job2", Me)
    
        Dim itm As Int = Starter.kvs.ListKeys.Get(i)
        Dim nummer As Int = Starter.kvs.Get(itm)
        Dim uren As Int = itm/360000
        Dim restant As Int =itm Mod 360000
        Dim minuten As Int = restant/6000
        restant =  restant Mod 6000
        Dim seconden As Int = restant/100
        Dim hondersten = restant Mod 100
        Dim carn As Int = nummer
        Dim past As Int = itm
        Dim past1 As String = uren & ":" & minuten & ":" & seconden & "." & hondersten  ''"11:11:11.23"

        Dim str As String = "https://xxxx.nl/xxxx/xxxxxx.php?Name=" & name & "&Point=" & Meetplaats & "&Number=" & carn & "&PassingTime2=" & past1 & "&PassingTime=" & past
        job2.PostString(str,"")

    Next

anybody a better suggestion for the script and a solution to get it into the db in the correct order?
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
As the poststring is in a tight loop, it is possible given the nature of the internet that they are not arriving in the order that they are sent.

Have you tried waiting until the previous poststring has completed before sending the next? I know that this will mean that it will take longer but it will preserve the order.

Alternatively, if the server side is yours then you could add another endpoint which accepted a list.

Cheers
 
Upvote 0

Amateurtje

Member
Licensed User
Longtime User
Hi Andrew, thanks for your fast response..

I do have some control over the php, although php is really new for me...

how would I wait for a poststring to be completed? There is Job2.complete, but it needs a id.. How to supply an id?

B4X:
job2.PostString(str,"")
wait for (job2) complete

This did not work.. That makes that only the first postscript is added.....
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…