Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Parsing a list

Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
05-10-2006 04:03
I have a list that consist of a sequence of number. The first number in the sequence defines the number of numbers that follow that are of specific type. For example, if the first number is the integer 1, then it will be followed by one float, and then another integer. If the first number is the integer 2, then it will be followed by two floats, and then two integers. What have not be able to do is the code that will correctly extract these sets of numbers. The following is one example of several I have tried to parse the list correctly.

//temp is a list with integers and floats
integer x = llList2Integer(temp, 0); // the number of floats and integers
integer i;
for (i = 1; i < x + 1 ; ++i)
{//These are floats
timeList = timeList + llList2Float(temp, i); //This seems to work
}
for (i = x; i < x*2 + 1 ; ++i)
{//These are integers
intList = intList + llList2Integer(temp, i); //This does not work
}

Would someone point me in the right direction?
Thanks, Mod
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
05-10-2006 04:31
Will the number of floats and integers always be even? if so, just break the list in half.

Otherwise, try something like

integer numberOfEach=llList2Integer(myList,0);
list floats = llList2List(myList, 1, numberOfEach);
list ints= llList2List(myList, 1+numberOfEach,1+2*numberOfEach );
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-11-2006 06:44
Perhaps you should look into llGetLinkEntryType.

That should save you tons of memory, by not having to store the list entry type.