Difference between revisions of "TrimList"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "this function will trim a list of strings for the output of a dialog box. '''Function''' <lsl> list TrimList(list dlist, integer length) { integer i; list temp = []; …")
 
m (<lsl> tag to <source>)
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:


'''Function'''
'''Function'''
<lsl>
<source lang="lsl2">
list TrimList(list dlist, integer length)  
list TrimList(list dlist, integer length)  
{
{
     integer i;
     integer i;
    integer dl = llGetListLength(dlist);
     list temp = [];
     list temp = [];
     for(i=0;i<llGetListLength(dlist);i++)
     while(~--dl)
    {
         temp += llGetSubString(llList2String(dlist,i++),0, length-1);
         string text = llList2String(dlist,i);
        if (length < llStringLength(text))
        {
            length = length-1;
            string newstring = llGetSubString(text,0, length);
            temp += newstring;
        }
        else
        {
            temp += text;
        }
    }
     return temp;
     return temp;
}
}


</lsl>
</source>


{{LSLC|User-Defined Functions}}
{{LSLC|User-Defined Functions}}

Latest revision as of 14:44, 22 January 2015

this function will trim a list of strings for the output of a dialog box.

Function

list TrimList(list dlist, integer length) 
{
    integer i;
    integer dl = llGetListLength(dlist);
    list temp = [];
    while(~--dl)
        temp += llGetSubString(llList2String(dlist,i++),0, length-1);
    return temp;
}