Difference between revisions of "LlListFindList"

From Second Life Wiki
Jump to navigation Jump to search
m
m (added "List: Find Last Index" and "List: Multi-Find Index" to also functions.)
Line 34: Line 34:
|also_functions=
|also_functions=
{{LSL DefineRow||[[llSubStringIndex]]|Find a string in another string}}
{{LSL DefineRow||[[llSubStringIndex]]|Find a string in another string}}
{{LSL DefineRow||[[User:Void_Singer/Functions#List:_Find_Last_Index|List: Find Last Index]]|Returns an integer that is the index of the '''last''' instance of test in src.}}
{{LSL DefineRow||[[User:Void_Singer/Functions#List:_Multi-Find_Index_.28First_or_Last.29|List: Multi-Find Index (First_or_Last)]]|Get first(or last) Index of '''any''' matching elements of test in src.}}
|also_events
|also_events
|also_tests
|also_tests

Revision as of 00:31, 16 July 2009

Summary

Function: integer llListFindList( list src, list test );

Returns an integer that is the index of the first instance of test in src.

• list src
• list test

If test is not found in src, -1 is returned.
The index of the first entry in the list is 0

Caveats

  • Strict type matching and case sensitivity is enforced.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>list numbers = [1, 2, 3, 4, 5]; default {

   state_entry()
   {
       integer index = llListFindList(numbers, [3]);
       if (index != -1)
       {
           list three_four = llList2List(numbers, index, index + 1);
           llOwnerSay(llDumpList2String(three_four, ","));
           // Object: 3,4
       }
   }
}</lsl>

Useful Snippets

An easy way to see if an item exists in a list... <lsl>if(~llListFindList(myList, (list)item)) {//it exists

   //This works because ~(-1) == 0
   //It saves bytecode and is faster then doing != -1

}</lsl>

See Also

Functions

•  llSubStringIndex Find a string in another string
•  List: Find Last Index Returns an integer that is the index of the last instance of test in src.
•  List: Multi-Find Index (First_or_Last) Get first(or last) Index of any matching elements of test in src.

Deep Notes

Search JIRA for related Issues

Signature

function integer llListFindList( list src, list test );