Difference between revisions of "ListItemReplace"

From Second Life Wiki
Jump to navigation Jump to search
(Better use llOwnerSay maybe data is sensitive O.o)
m
Line 1: Line 1:
{{LSL Header}} __NOTOC__
{{LSL Header}} __NOTOC__
[[Category:LSL_UD_Functions]]
<div id="box">
<div id="box">
== Function: [[list]] ListItemReplace([[list]] {{LSL Param|mylist}}, [[string]] {{LSL Param|element_old}},[[string]] {{LSL Param|element_new}} ); ==
== Function: [[list]] ListItemReplace([[list]] {{LSL Param|mylist}}, [[string]] {{LSL Param|element_old}},[[string]] {{LSL Param|element_new}} ); ==

Revision as of 09:36, 25 May 2010

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);    
   }
   llOwnerSay("ERROR: Element '" + element_old + "' not found in list [" + llList2CSV(mylist) + "]" );
   return mylist;

} </lsl>


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