Help with URL blocking/non-blocking code

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tonymac
Posts: 23
Joined: Thu Jan 05, 2012 9:17 pm

Help with URL blocking/non-blocking code

Post by tonymac » Wed Dec 03, 2014 6:03 pm

Windows 7 - Livecode 7.0.1 (rc 2)

Got a URL that is a PHP file that I call in a separate handler in an OpenStack. It posts the date/time into a MySql database table. The line of code after it "types" a sentence into a feedback field. Using the SEND: "send "TypeInfo" to me in 20 milliseconds" to enter the characters into the field. The typing pauses until the PHP URL handler finishes posting the date/time in the database. Tried post/get/put/load and all "seem" to be blocking. I might be misunderstanding this but I thought using GET would would execute its line of code and then go on to the rest of the script but it definitely waits until a response from the GET script.

Not exactly all the code but something like this:

on OpenStack
PostDateTime
put "Click the MENU button above to start." into TheInfo
TypeInfo
end OpenStack
------------------------------
on PostDateTime
GET URL ".../PostDateTime.php"
end PostDateTime
------------------------------
on TypeInfo
if InfoChar <= TotalChars then
put char InfoChar of TheInfo after field "Feedback"
send "TypeInfo" to me in 20 milliseconds
end if
end TypeInfo

Thanks for any help.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Help with URL blocking/non-blocking code

Post by sturgis » Tue Dec 16, 2014 9:04 pm

Look at the load command

Code: Select all

on openstack
load URL "http://the.url.to.load" with "completed"
end openstack

command completed pVar1,pVar2
put URL pVar1 into <wherever you want to put it>
unload pVar1 -- free up the cached page

end completed
the callback message is passed 2 parameters when its called. The first is the URL in question, the second is the status, so if you have issues, check the 2nd parameter for an error.

Be aware, IOS and android work slightly different. (last time I checked) and don't cache the URL, so you must check the contents of pvar1 and pvar2 (whatever you name them..) to get the contents.

I don't have a way to explain the exact differences at the moment. Not set up for mobile on this system.

Klaus
Posts: 13866
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Help with URL blocking/non-blocking code

Post by Klaus » Wed Dec 17, 2014 1:02 pm

To be precise:
...
load URL "http://the.url.to.load" with MESSAGE "completed"
...
8)

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Help with URL blocking/non-blocking code

Post by sturgis » Wed Dec 17, 2014 4:05 pm

DOH. Yep, this is my week (month, year) for absent mindedness. Thx Klaus

Post Reply

Return to “Internet”