Difference between revisions of "LlParseString2List"

From Second Life Wiki
Jump to navigation Jump to search
m (LSL llParseString2List moved to LlParseString2List: removing prefix)
Line 6: Line 6:
|return_text=that is '''src''' broken into a list, discarding '''separators''', keeping '''spacers''', discards any null values generated.
|return_text=that is '''src''' broken into a list, discarding '''separators''', keeping '''spacers''', discards any null values generated.
|spec
|spec
|caveats
|caveats=*Every element in the list will be a string, no matter what you think it should be. Cast the results of llList2String to get what you want.
** ''integer my_int = (integer)llList2String(my_list,i);''
|constants
|constants
|examples
|examples=<pre>default
{
    state_entry()
    {
        // This will say:
        // <A><crazy><fox><.><Saw><the><moon><.><.>
        string my_string = "A crazy fox.  Saw the moon..";
        list my_list = llParseString2List(my_string,[" "],["."]);
        llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");
       
        // This will say:
        //  <A><crazy><fox><.><><><Saw><the><moon><.><><.><>
        my_list = llParseStringKeepNulls(my_string,[" "],["."]);
        llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");
    }
}</pre>
|helpers
|helpers
|also_functions=*{{LSLG|llParseStringKeepNulls}}
|also_functions=*{{LSLG|llParseStringKeepNulls}}

Revision as of 16:11, 8 March 2007

Summary

Function: list llParseString2List( string src, list separators, list spacers );
0.0 Forced Delay
10.0 Energy

Returns a list that is src broken into a list, discarding separators, keeping spacers, discards any null values generated.

• string src
• list separators
• list spacers

separators and spacers must be lists of strings, maximum of 8 each.

Caveats

  • Every element in the list will be a string, no matter what you think it should be. Cast the results of llList2String to get what you want.
    • integer my_int = (integer)llList2String(my_list,i);

Examples

default
{
    state_entry()
    {
        // This will say:
        // <A><crazy><fox><.><Saw><the><moon><.><.>
        string my_string = "A crazy fox.  Saw the moon..";
        list my_list = llParseString2List(my_string,[" "],["."]);
        llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");
        
        // This will say:
        //  <A><crazy><fox><.><><><Saw><the><moon><.><><.><>
        my_list = llParseStringKeepNulls(my_string,[" "],["."]);
        llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");
    }
}

Deep Notes

Signature

function list llParseString2List( string src, list separators, list spacers );