ListItemReplace

From Second Life Wiki
Revision as of 11:35, 26 September 2009 by Virtouse Lilienthal (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Function: list ListItemReplace(list mylist, string element_old,string element_new );

Replaces a single occurrence of something in a list with something else that you specify.

See also: Lists

<lsl> list ListItemReplace(list mylist,string element_old, string element_new) {

   integer placeinlist = llListFindList(mylist, [element_old]);
   if ( placeinlist != -1 ) {
       return llListReplaceList(mylist, [element_new], placeinlist, placeinlist);    
   }
   llSay(0, "ERROR: Element '" + element_old + "' not found in list");
   return mylist;

} </lsl>


list myupdatedList = ListItemReplace(mylist,"Brown","Blue");