Difference between revisions of "LlParseString2List"

From Second Life Wiki
Jump to: navigation, search
(explicitly state all four preconditions)
(the caveats didn't explain what would happen)
Line 8: Line 8:
 
|func_footnote
 
|func_footnote
 
|func_desc
 
|func_desc
|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 of strings, discarding '''separators''', keeping '''spacers''', discards any null values generated.
 
|spec
 
|spec
 
|caveats=
 
|caveats=
* Never provide more than 8 separators, never provide more than 8 spacers.
+
* Only the first 8 separators and first 8 spacers will be used any extras will be ignored.
* Provide lists of strings as the separators and spacers, not mixed lists of strings and floats and such.
+
* All separators and spacers must be strings, all other types will be ignored.
* Don't let any spacer contain or equal a separator, and don't let any separator contain or equal a spacer.
+
* Separators take precedent over spacers. The string is parsed from start to finish, each position is compared against the separators then spacers before moving onto the next position.
* Do list each spacer and separator only once.
+
* Duplicates are ignored.
* Do expect to receive a list of strings in return. Call functions like [[llList2Integer]] to get the [[llGetListEntryType]] type that you want. Read those caveats too, ''e.g.'', cast to integer from llList2String if you want to receive a hexadecimal integer.
+
* All entries in the return are typed as string. Use explicit typecasting on [[llList2String]] to convert the values into other types. Do not rely upon the implicit typecasting of the other llList2* functions (as they are typically incomplete).
 
|constants
 
|constants
 
|examples=<pre>default
 
|examples=<pre>default
Line 40: Line 40:
 
Also correct at a glance.}}
 
Also correct at a glance.}}
 
{{!}}}
 
{{!}}}
|also_functions=*{{LSLG|llParseStringKeepNulls}}
+
|also_functions={{LSL DefineRow||[[llParseStringKeepNulls]]}}
*{{LSLG|llDumpList2String}}
+
{{LSL DefineRow||[[llDumpList2String]]}}
*{{LSLG|llCSV2List}}
+
{{LSL DefineRow||[[llCSV2List]]}}
*{{LSLG|llList2CSV}}
+
{{LSL DefineRow||[[llList2CSV]]}}
 
|also_events
 
|also_events
 
|also_tests
 
|also_tests
|also_articles=*{{LSLG|Separate Words}}
+
|also_articles={{LSL DefineRow||[[Separate Words]]}}
*{{LSLG|LSLEditorBugs}}
+
{{LSL DefineRow||[[LSL-Editor/Bugs]]}}
 
|notes
 
|notes
 
|permission
 
|permission

Revision as of 05:46, 2 October 2007

Summary

Function: list llParseString2List( string src, list separators, list spacers );

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

• string src source string
• list separators separators to be discarded
• list spacers spacers to be kept

Caveats

  • Only the first 8 separators and first 8 spacers will be used any extras will be ignored.
  • All separators and spacers must be strings, all other types will be ignored.
  • Separators take precedent over spacers. The string is parsed from start to finish, each position is compared against the separators then spacers before moving onto the next position.
  • Duplicates are ignored.
  • All entries in the return are typed as string. Use explicit typecasting on llList2String to convert the values into other types. Do not rely upon the implicit typecasting of the other llList2* functions (as they are typically incomplete).
All Issues ~ Search JIRA for related Bugs

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,"><") + ">");
    }
}

Useful Snippets

Examples of processing more than 8 spacers or separators:

•  ParseString2List Functions exactly the same as llParseString2List and llParseStringKeepNulls.
•  separateWords Functions exactly the same as llParseString2List unless you violate the preconditions.

Also correct at a glance.

See Also

Functions

•  llParseStringKeepNulls
•  llDumpList2String
•  llCSV2List
•  llList2CSV

Articles

•  Separate Words
•  LSL-Editor/Bugs

Deep Notes

Search JIRA for related Issues

Signature

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