Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to get a value out a list?

Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
10-06-2009 09:55
Hi all,

If i have a notecard with 4 values a line and several lines and place them with a notecard reader in a list. What is then the best way to get 4 values in 4 different variables everytime i go to a new line in the list? To place lines from a notecard in a list i know but i can't find how to get a value out a list if there are more values at 1 line.

Example in pseudo code
/notcard
string1, string2, string3, integer4
stringA, stringB, stringC, integerD
several more lines
/end notecard

/Script
notecard reader read all in list Products

movefirst
variable1=products.line1.value1(string1)
variable2=products.line1.value2(string2)
variable3=products.line1.value3(string3)
variable4=products.line1.value4(integer4)

after a movenext
variable1=products.line2.value1(stringA)
variable2=products.line2.value2(stringB)
variable3=products.line2.value3(stringC)
variable4=products.line2.value4(integerD)
/End script


Or is it better that the notecard reader splits the 4 values in 4 different lists?

Thanks

Kaylan
Pete Littlebird
Registered User
Join date: 30 Sep 2009
Posts: 44
10-06-2009 10:23
LlParseString2List http://wiki.secondlife.com/wiki/LlParseString2List.
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
10-06-2009 10:50
thanks for your answer.

Do you mean to break the notecard lines in 4 entries in the list?

this will create (i think):
list Product =[ "string1", "string2", "string3", "integer4", "stringA", "stringB", "stringC"," integerD"]

or use LlParseString2List on each line of the orginal list products and create a new 'sub'
list with only 4 values?

Think both would work but which is the best? (less lag)
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
10-06-2009 11:02
I think you might be looking for llList2String
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
10-06-2009 12:07
if i understand it well it will be something like this?

list Products;
integer LineNr

list Items = llParseString2List(llList2String(Products, LineNR))

string variable1 = llList2String(Items, 0)
string variable2 = llList2String(Items, 1)
string variable3 = llList2String(Items, 1)
string variable4 = llList2String(Items, 3)

Think i start endly understand a little of lists :)
Vance Adder
Registered User
Join date: 29 Jan 2009
Posts: 402
10-06-2009 12:11
If it were me, I'd probably do it in one list.

So then if you wanted to refer to them you might do...

variable1 = llList2String(nIndex, products);
variable2 = llList2String(nIndex+1, products);
variable3 = llList2String(nIndex+2, products);
variable4 = llList2Integer(nIndex+3, products);

-edit- I may have put those parameters in backwards, lol
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
10-07-2009 13:34
if i do it in 1 list i get to much information
the orginal products list has 4 items a line

i only want 1 of the 4 items

variable1 = llList2String(products, nIndex) gives "string1, string2, string3, integer4"

or do is see something wrong?
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
10-08-2009 09:26
Try llCSV2List, it works with commas, but you'll want to be careful of what string-data you have in your notecard.

So your dataserver event might looking something like:

CODE
dataserver(key id, string data) {
list parts = llCSV2List((data = "") + data);
string variable1 = llList2String(parts, 0);
string variable2 = llList2String(parts, 1);
string variable3 = llList2String(parts, 2);
integer variable4 = llList2Integer(parts, 3);
}


Obviously you can trim out some of those lines to get the values you want.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)