listItemDelete

From Second Life Wiki
Revision as of 19:21, 8 March 2010 by Reynard Baroque (talk | contribs) (Item to remove from the list was specified as a list, when the code in "Specification" shows it's a string.)
Jump to navigation Jump to search

Summary

Function: list ListItemDelete( list mylist, string element );

Returns a list that is a copy of mylist but with the first instance of element removed.

• list mylist list to remove items from
• string element item to remove from mylist

See also: Lists

Specification

<lsl>list ListItemDelete(list mylist,string element_old) {

   integer placeinlist = llListFindList(mylist, [element_old]);
   if (placeinlist != -1)
       return llDeleteSubList(mylist, placeinlist, placeinlist);
   return mylist;

}</lsl>

Examples

<lsl> list mylist = ["Red", "Green", "Blue", "Brown"]; list myShortenedList = ListItemDelete(mylist, "Brown");

//myShortenedList is now ["Red", "Green", "Blue"]</lsl>