|
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
|
01-15-2008 18:26
i would like to make a notecard and make each line into its own list
what i plan on doin is seperating the list in 2 and relying on the 2nd part of the list as my option
notecard would say
APPLECOUNT=1 ORANGECOUNT=2 PEARCOUNT=3 LINDENCOUNT=0
i want each one to be its own list if someone can show me a script to do this i would appreciate it
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
01-15-2008 18:45
But, why a separate list for each line? If the script will use these values as I kinda expect it will, it would be handier to make one "alist" ( http://en.wikipedia.org/wiki/Association_list#Association_lists), appending the key and value from each notecard line. Before I ramble, though, maybe something totally different is intended.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-15-2008 21:37
I'm guessing you want list a = ["APPLECOUNT",1]; list b = ["ORANGECOUNT",2]; list c = ["PEARCOUNT",3]; list d = ["LINDENCOUNT",0];
the best way to actually do this is a strided list
list a = ["APPLECOUNT", 1, "ORANGECOUNT", 2, "PEARCOUNT", 3, "LINDENCOUNT", 0];
then to find each set you list find the variable you want, add one to the returned index, and that's the variable that goes with it.
there is no way to dynamically create variables (you could work around it by using self giving scripts but I wouldn't reccomend it) so a strided list is your best option... you can even return a sublist using lst 2 list if it's more complex and gets fed to something else.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-15-2008 22:21
I'm also rather fond of parallel lists myself. Helps with searches when (some) values happen to be strings (or the same type as the natural index, anyway). Wrap them with nice helper functions to insert and remove, and it works pretty nicely. E.g.: list fieldNames = [ "APPLECOUNT", "ORANGECOUNT", "PEARCOUNT", "LINDENCOUNT" ]; list fieldValues = [ 1, 2, 3, 0 ]; integer nFields = 4;
addField(string name, integer value) { fieldNames = (fieldNames=[])+fieldNames+name; fieldValues = (fieldValues=[])+fieldValues+value; ++nFields; }
removeField(integer index) { fieldNames = llDeleteSubList(fieldNames, index, index); fieldValues = llDeleteSubList(fieldValues, index, index); --nFields; }
|