Difference between revisions of "LlListInsertList"

From Second Life Wiki
Jump to navigation Jump to search
(I think this rewording should make it harder to assume the function modifies the input parameters.)
m
Line 5: Line 5:
|func_footnote
|func_footnote
|func_desc
|func_desc
|return_text=that contains all the elements from '''dest''' but with the elements of '''src''' inserted at position '''start'''.
|return_text=that contains all the elements from '''dest''' but with the elements from '''src''' inserted at position '''start'''.
|spec
|spec
|caveats
|caveats

Revision as of 19:10, 14 July 2008

Summary

Function: list llListInsertList( list dest, list src, integer start );
0.0 Forced Delay
10.0 Energy

Returns a list that contains all the elements from dest but with the elements from src inserted at position start.

• list dest
• list src
• integer start

start supports negative indexes.

Specification

Index Positive Negative
First 0 -length
Last length - 1 -1

Indexes

  • Positive indexes count from the beginning, the first item being indexed as 0, the last as (length - 1).
  • Negative indexes count from the far end, the first item being indexed as -length, the last as -1.

Caveats

  • If start is out of bounds the script continues to execute without an error message.

Examples

<lsl> list numbers = [3, "three", 2, "two", 1, "one"]; default {

   state_entry()
   {
       llOwnerSay(llDumpList2String(numbers, ","));
       // Object: 3,three,2,two,1,one
       integer index = llListFindList(numbers, [2]);
       if (index != -1)
       {
           numbers = llListInsertList(numbers, [2.5, "two and a half"], index);
           llOwnerSay(llDumpList2String(numbers, ","));
           // Object: 3,three,2.500000,two and a half,2,two,1,one
       }
   }

}

</lsl>

Notes

Bear in mind that the source list will remain unchanged. Instead, a new list will be produced. So, it's important that you capture this with a variable (unless you are acting directly on the results.)


Tip! To insert something at the start of a list, you can just add the two lists (putting the list with the new item(s) first)

<lsl> list oldList = ["B", "C", "D"]; list newItem = ["A"]; list newlist = newItem + oldList; </lsl>

See Also

Functions

• llDeleteSubList
• llList2List
• llListReplaceList

Articles

•  Negative Index

Deep Notes

Signature

function list llListInsertList( list dest, list src, integer start );