Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llString2Link()

Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-26-2005 15:56
OOPS... there isn't one. There is something close: llParseString2List

But I was not able to understand how to get:

string mystring="abcdef";

list mylist = llParseString2List(mystring,????????);

so that mylist would be "["a", "b", "c", "d", "e","f"]"

is there a way?
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
03-26-2005 17:30
Are you wanting to create a list of each charater in the string as a separate element? If so something like:

for(i=0; i<llGetStringLength(myString); ++i)
{
myList+=llGetSubString(myString, i, i);
}

ought to do the trick...
Jack Lambert
Registered User
Join date: 4 Jun 2004
Posts: 265
03-26-2005 19:21
To clarify the above a little more, unless you really need the list, you would normally leave the string intact and use llGetSubString() to extrapolate portions of it.

--Jack Lambert
_____________________
----------------------------
Taunt you with a tree filled lot? hahahahahahaha. Griefer trees! Good lord you're a drama queen. Poor poor put upon you.

-Chip Midnight
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-28-2005 09:14
The reason I wanted to extract the characters to a list was because I want to manipulate each character separately. So I will use the substring method that Eloise mentioned. I was trying NOT to do that... but try as I might, that seems like it will not work.

Next, I thought, ok, now where is my list replacement function... once again there isn't one. The Wiki offers:

CODE
// replaces item number _pos_ in list _dest_ with list _src_
// negative values for _pos_ means count from the end of
// the list instead, so a _pos_ of -1 means replace the last item in the list
list ListReplaceList(list dest, list src, integer pos) {
if (pos < 0) pos = llGetListLength(dest) + pos;
return llListInsertList(llDeleteSubList(dest, pos, pos), src, pos);
}


I see that it says list "replaces item number _pos_ in list _dest_ with list _src_"

with the list: list MyList = "["a", "b", "c", "d", "e","f"]";

if I did ListReplaceList(Mylist, "["X"]",2)

would that result with:

["a", "b", "X", "d", "e","f"]

? (seeing as how the first element in the list is indexed at zero?
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
03-28-2005 14:27
Yes, as I understand it, although I've not actually tried the code out.
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-28-2005 16:50
Thanks again Eloise for the reply.

I just tried it. At first glipse it compiles, but does not seem to work. Details:

By the way, good code for the separation of the bits in the string to the list. That part worked well, and I did a test "for loop" to prove it.

So now, I'm in the middle of a for loop... matching parts of two lists.

When the parts match, I am re-writing them so they are SURE not to match again.

I THOUGHT I would be able to do this:
assuming the "i" is the incrementing element in the for loop...

ListReplaceList(lList, ["X"], i);

Should that not replace the i'th element in 'lList'

So for example, if i = 2 should be the 3rd digit. (0, 1, 2)...

to test this, I should then be able to:

llWhisper(0, "lList= " + llDumpList2String(lList, "";));

and be able to confirm that the 3rd digit changed?

Or am I way out in left field and do not have a clue why?

(anyone?)... I waited to come home and test this and this is what is happening.
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
03-29-2005 03:16
I just tried this:

CODE

string myString = "abcdef";
list myList;
list newList;

default
{
state_entry()
{
integer i;
for(i=0; i<llStringLength(myString); ++i)
{
myList+=llGetSubString(myString, i, i);
}
}

touch_start(integer total_number)
{
newList=llListInsertList(llDeleteSubList(myList, 2, 2), ["X"], 2);
llSay(0, llDumpList2String(newList, "+"));
}
}

and got this output when I touched it:

Object: a+b+X+d+e+f

I'm peering blearily at your code and wondering what the difference is, but it seems to me that this is working, and that it looks the same as your, except I've hard coded the function call, and missed the reset pos if negative line. Maybe if your eyes and brains are working this will help?
Tiger Crossing
The Prim Maker
Join date: 18 Aug 2003
Posts: 1,560
03-29-2005 06:02
Looking at all this, it seems to me (unless there is further code not listed here) that it would be easier to just keep the text in string form and use similar string manipulation commands to do the same thing without the conversion between string and list and back.
_____________________
~ Tiger Crossing
~ (Nonsanity)
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-29-2005 19:28
Nah changing the character in the string may not be as helpful as it might sound due to the other manipulations I have to do.

The sad thing is, I pulled the "function" from the Wiki, and it does not seem to do what it says it is supposed to do.

I'll look at Eloise's code again and see if it does what I need.

If not, I'll be back! =)
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-29-2005 20:06
I was looking for something else when I ran across this wiki entry:

llListReplaceList

So I will have to try this and see if it does the job....?? (where did that come from?)
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-29-2005 20:13
oh that was very funny. A hoax page....There is no such thing as llListReplaceList!!

What good is the Wiki if people are going to be permitted to post things in there that are just trash?
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
03-29-2005 20:17
From: Samhain Broom
oh that was very funny. A hoax page....There is no such thing as llListReplaceList!!

What good is the Wiki if people are going to be permitted to post things in there that are just trash?

Not a hoax, that's comming in 1.6
_____________________
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
Oh thank you!!
03-29-2005 22:10
Ok and whew!! I just tried some other tests, and discovered that the wiki example works and probably JUST as I thought it did. I THOUGHT I tested it out, and it did not work the first time and I was sure it wasn't my error... oops...

Thanks to everyone who helped!
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts