ListItemReplace

From Second Life Wiki
Revision as of 14:20, 22 January 2015 by ObviousAltIsObvious Resident (talk | contribs) (<lsl> tag to <source>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

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;
}


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