Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
03-31-2005 19:42
Lists are starting to be the bane of my existance.
I am trying to add a string to a list.
Can I do this?
string mystring = "foo"
list mylist = [mystring]
mystring = "bar"
mylist = mylist + [mystring]
so that now mylist should equal:
["foo", "bar"]
doesn't it work that way?
Also, should you not be able to do:
mylist += [anotherVariable]
to increment the list? (or is that too much to ask for?)
*sigh*
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
|
03-31-2005 20:04
default { state_entry() { string mystring = "foo";
list mylist = [mystring];
mystring = "bar";
mylist = mylist + [mystring]; llSay(0, llList2CSV(mylist)); integer anotherVariable = 9; mylist += [anotherVariable] ; llSay(0, llList2CSV(mylist)); } }
This outputs: Object: foo, bar Object: foo, bar, 9 Looks fine to me!
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
03-31-2005 20:09
I do not know what is wrong with my code... but I can confirm that the following works: default { state_entry() { list mylist = []; string a = "123"; mylist += [a]; a = "456"; mylist += [a]; a = "789"; mylist += [a]; string out = llDumpList2String(mylist, "\n"); llWhisper(0, "out = " + out); } }
The output worked as expected with 123 then a carriage return, then 456 carriage return, then 789... I have some code troubleshooting to do! That's all there is to it! Sorry I wasted yer time people!
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Konigmann Lippmann
Registered User
Join date: 15 Jun 2004
Posts: 40
|
llListInsertList()
04-01-2005 22:10
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
04-02-2005 10:20
You can try some of these:
<code> list theList;
theList = ["foo","bar"];
theList = theList + ["baz"];
theList += ["moof"];
theList = theList + "gleep";
theList += "qux"; </code>
By the end of that, the list contains ["foo","bar","baz","moof","gleep","qux"]. The point is, you can add a lsit on, and you can also just add any data type to a list to have it appended as an item in that list.
|