Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llHTTPRequest question

Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
10-01-2007 09:21
hi,
this is a whole new level of scripting to me, so maybe could give me some advice on the script i'm working on.

Here is what i want to do:

*Send llHTTPRequest to a server
*Receive data
*Read certain information out of the feedback
*Display it in chat

So far i did some research and found a script in the wiki, that helped me to do the first 2 steps.

//begin script

string URL="http://www.secondlife.com/httprequest/homepage.php";
//Replace URL with the path to your web server.
key http;//This stores the HTTP request we send.

default
{
touch_start(integer foo)
{
http=llHTTPRequest(URL, [] ,"";);
}

http_response(key id,integer status, list meta, string body)
{
if(http==id)
{
integer i;
list lbody=llParseString2List(body,["\n"],[]);
integer count=llGetListLength(lbody);
//This turns newline characters char(10) into new lines in chat
//These are Unix/LSL style end of lines, use \r\n in place of \n for
// Windows style end of line from web server.
for(i=0;i<count;i++)
{
llOwnerSay(llList2String(lbody,i));
}
}
}
}

//end script

I pretty much understood what it does and it shows the server feedback in chat.

Now, my problem is, how to get to the special part of the information in the feedback, I want.
So, let's say the information I need is in line 15. Would it be correct to count all lines, go to line 15, read the string (maybe split it up) and then display it?

Maybe someone can give me advice on solving this problem.

Any help appreciated. Thank you very much!
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
10-01-2007 11:51
What you have there in the http_response event is a function which turns the received response into a list, splitting it up according to newline characters, so that list element X will have been preceded by X newlines. So yes, if you want to find line X of the response, look at the 15th element of the list (of course, list numbering starts at 0, so you will be looking at element 14).
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
10-01-2007 12:48
thank you very much...I'll try a few things and post updated info...
Siann Beck
Beauty & Braiiiiinsss!
Join date: 14 Jul 2007
Posts: 140
10-01-2007 13:00
Don't forget that the body of the response is limited to 2048 characters; if it's longer it will simply be truncated.