integer llListFindList(list src, list test)
the position (index) of the first instance of test
isn't in src
When using this function
, please remember that the type
have to be the same, so typecast values
to what they are expected to be in src
if they're variable
s. Remember, this does
If unsure what type the variables may be, use a for loop
to check the output of llList2String()
against the string to test for.
list src = ["The", "Quick", "Brown", "Fox", "Jumped", "Over", "The", "Lazy", "Dog"];
test = ["Brown"]; // What we want to find.
integer foxColorIndex = llListFindList(src, test); // Returns 2.
test = ["Jumped", "Over"];
integer whatFoxDidIndex = llListFindList(src, test); // Returns 4.
test = ["Quick", "Fox"];
integer thereIsNoFox = llListFindList(src, test); // Returns -1.
To do this with a string, use llSubStringIndex
Q: How do I figure out the indexes of ALL instances of test?
A: There isn't a direct function to do this. Your best method is probably to do something like find out how many entries the list has using llGetListLength, then use a FOR loop, cutting out every instance of test, then replacing them after they've all been removed. If you can at all avoid it, use llListFindList to simply make sure you don't have any duplicates to begin with.
A2: Alternatively, if your list's order isn't important, you could use llListSort to put your list into alphabetical order, use llListFindList to get the index of the first entry, then simply incrementing by one until you stop finding matches. Obviously, if list order is important, this won't work.
A3: You can also use multiple instance of the llListFindList instead of doing a FOR loop for multiple choices.
This article wasn't helpful for you? Maybe the related article at the LSL Portal
is able to bring enlightenment.