Difference between revisions of "PartMatchStrInList"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "==Description== A way to find a partial match in a list with a string (because there wasn't another one on this wiki at the time of writing) ==Code== <lsl> //Made by Richardjrn …")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
==Description==
==Description==
A way to find a partial match in a list with a string (because there wasn't another one on this wiki at the time of writing)
A way to find the first partial match in a list with a string (because there wasn't another one on this wiki at the time of writing)


==Code==
==Code==
Line 12: Line 12:
     {
     {
         string match = llList2String(src,i);
         string match = llList2String(src,i);
         if(llSubStringIndex(match,search)!=-1)return match;
         if(llSubStringIndex(llToLower(match),llToLower(search))!=-1)return match;
     }
     }
     return "NoThInG_FoUnD";
     return "NoThInG_FoUnD";
}
}
</lsl>
</lsl>

Latest revision as of 06:45, 21 November 2012

Description

A way to find the first partial match in a list with a string (because there wasn't another one on this wiki at the time of writing)

Code

<lsl> //Made by Richardjrn Weatherwax string PartMatchStrInList(string search, list src) {

   integer kill = FALSE;
   integer i;
   for(i=0;i<llGetListLength(src);i++)
   {
       string match = llList2String(src,i);
       if(llSubStringIndex(llToLower(match),llToLower(search))!=-1)return match;
   }
   return "NoThInG_FoUnD";

} </lsl>