Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

ASP variables

pi Mip
Registered User
Join date: 18 Jan 2007
Posts: 20
01-28-2007 12:07
Hi... I'm an ASP programmer and I want to send variables to my SL script.

I've done ASP to flash before... but there, actionscript just looks for a list, returned via HTTP like:

CODE

var1=apple
var2=pear


Does SL read variables like this, or does it only parse XML?



Thanks,

pi Mip
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
01-28-2007 13:35
No, you have to script any interaction yourself using LSL. Use llHttpRequest() request to get the variables from your server. You could grab a single string with several variable:data pairs. In LSL, you could parse the string using functions such as LLCSV2List() or llParseString2List().
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
01-28-2007 14:49
SL only reads plaintext sent from the webpage within the body of the event ... but it reads it as a string so your example would show up as "var1=apple\nvar2=pear"
pi Mip
Registered User
Join date: 18 Jan 2007
Posts: 20
01-28-2007 14:54
From: Osgeld Barmy
SL only reads plaintext sent from the webpage within the body of the event ... but it reads it as a string so your example would show up as "var1=apple\nvar2=pear"


Thanks!

So, I would parse the string "manually" in my SL script? Or does SL script have a function that understands that format?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-28-2007 15:06
From: pi Mip
Thanks!

So, I would parse the string "manually" in my SL script? Or does SL script have a function that understands that format?



Use llParseString2List to split the lines, and then a second time to process each pair

CODE

ProcessData(string str)
{
list ldata = llParseString2List(str, ["\n"], [""]);
integer size = llGetListLength(ldata);
while(size >= 1)
{
string x = llList2String(ldata,size);
list commands = llParseString2List(x, ["="], [""]);
string varname = llList2String(commands,0);
string value = llList2String(commands,1);
// Do what ever
--size;
}
}
pi Mip
Registered User
Join date: 18 Jan 2007
Posts: 20
01-28-2007 15:08
Thanks guys.

I appreciate it very much.




-pi Mip