Talk:LlParseString2List

From Second Life Wiki
Revision as of 18:36, 29 April 2010 by Fred Gandt (talk | contribs) (I think llParseString2 and llParseStringKeep need new examples. I wonder if we might pull together to produce something better than either what is already in place or my effort here?)
Jump to navigation Jump to search
  • Is there a limit to the number of items that this function will parse into a list? —The preceding unsigned comment was added by Bobby Fairweather
    • Yes there is a limit, the amount of free memory the script has. —The preceding unsigned comment was added by Strife Onizuka

A replacement of the examples for llParseString2List and llParseStringKeepNulls.

I feel that the present examples are too confusing to read and don't really help teach what the functions do (I find the repeated <<>>><<<>><<> totally baffling). I tried to write an example myself but think it fails to show the functions at their best (it just sucks to be frank) but is easier to read and IMO clearer to understand what these functions do. Could we pull together and sort something out? Thus far - <lsl> default {

   state_entry()
   {
       // We have a string of text that we want to adapt.
       string source = "How much wood would a woodchuck chuck if a woodchuck could chuck wood?";
       
       // We use this function to replace elements with others of our choosing.
       
       // We remove all instances of "much" and put in place (by using llDumpList2String) "many".
       source = llDumpList2String(llParseString2List(source, ["much"], []), "many");
       // Our source is now "How many wood would a woodchuck chuck if a woodchuck could chuck wood?"
       
       // We remove all instances of "chuck" and replace with "rez".
       source = llDumpList2String(llParseString2List(source, ["chuck"], []), "rez");
       // Our source is now "How many wood would a woodrez rez if a woodrez could rez wood?"
       
       // We remove all instances of "wood" and replace with "prims".
       source = llDumpList2String(llParseString2List(source, ["wood"], []), "prims");
       // Our source is now "How many prims would a primsrez rez if a primsrez could rez prims?"
       
       // We remove all instances of "primsrez" and replace with "primrez".
       source = llDumpList2String(llParseString2List(source, ["primsrez"], []), "primrez");
       // Our source is now "How many prims would a primrez rez if a primrez could rez prims?"
       
       llOwnerSay(source); // Say the result to the owner.
       
       // There comes an issue though...
       
       source = "Peter Piper picked a peck of pickled pepper.";
       llOwnerSay(llDumpList2String(llParseString2List(source, ["P", "p"], []), "m"));
       //Returns "eter mimer micked a meck of mickled memer."
       
       // Notice that ALL the p's are gone and llDumpList2String adds "m" only where the split ocurred.
       
       // We can then use llParseStringKeepNulls instead.
       
       llOwnerSay(llDumpList2String(llParseStringKeepNulls(source, ["P", "p"], []), "m"));
       //Returns "meter mimer micked a meck of mickled memmer."
   }

} </lsl> -- Fred Gandt (talk|contribs) 01:36, 30 April 2010 (UTC)