Difference between revisions of "LlParseStringKeepNulls"

From Second Life Wiki
Jump to navigation Jump to search
Line 9: Line 9:
|func_desc
|func_desc
|return_text=that is '''src''' broken into a list, discarding '''separators''', keeping '''spacers''', keeping any null values generated.
|return_text=that is '''src''' broken into a list, discarding '''separators''', keeping '''spacers''', keeping any null values generated.
|spec
|spec=
The behavior is identical to that for [[llParseString2List]], except blank strings found in the list are kept. This is useful when parsing a list that contains values that can be null or empty (and subsequently removing the nulls would upset the distribution of data and the element indexs).
 
llParseListKeepNulls("", ["~"], []) will return [""]
|caveats=
|caveats=
The behaviour is identical to that for [[llParseString2List]], except blank strings found in the list are kept. This is useful when, if you lost them, the order of things in the list would change, and that would impact what you expect to find, where.
llGetListLength(llParseListKeepNulls("", ["]_["], [])) will equal 1, even though you might think the list is empty (it actually has 1 value in it, even if that value happens to be empty.)
* Only the first 8 separators and first 8 spacers will be used any extras will be ignored.
* 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.
* All separators and spacers must be strings, all other types will be ignored.
Line 21: Line 20:
* 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 typically return a default value).
* 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 typically return a default value).
|constants
|constants
|examples=<pre>default
|examples=<lsl>default
{
{
     state_entry()
     state_entry()
Line 36: Line 35:
         llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");
         llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");
     }
     }
}</pre>
}</lsl>
|helpers=
|helpers=
'''Replacement functions without or very large separator/spacer count limits'''
'''Replacement functions without or very large separator/spacer count limits'''
{{{!}}
{{{!}}
{{LSL DefineRow||[[ParseString2List]]|Functions exactly the same as [[llParseString2List]] and [[llParseStringKeepNulls]].}}
{{LSL DefineRow||[[ParseString2List]]|Functions exactly the same as [[llParseString2List]] and [[llParseStringKeepNulls]].}}
{{LSL DefineRow||[[Separate Words|separateWords]]|Functions exactly the same as [[llParseString2List]] unless you violate the preconditions.
{{LSL DefineRow||[[Separate Words|separateWords]]|Functions the same as [[llParseString2List]] unless certain preconditions are not met.}}
Also correct at a glance.}}
{{!}}}
{{!}}}
|also_functions=*{{LSLG|llParseString2List}}
|also_functions={{LSL DefineRow||[[llParseString2List]]}}
*{{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
|also_articles
|notes
|notes
|permission
|negative_index
|sort=ParseStringKeepNulls
|sort=ParseStringKeepNulls
|cat1=List
|cat1=List

Revision as of 04:51, 8 July 2008

Summary

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

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

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

Specification

The behavior is identical to that for llParseString2List, except blank strings found in the list are kept. This is useful when parsing a list that contains values that can be null or empty (and subsequently removing the nulls would upset the distribution of data and the element indexs).

llParseListKeepNulls("", ["~"], []) will return [""]

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 typically return a default value).
All Issues ~ Search JIRA for related Bugs

Examples

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

Useful Snippets

Replacement functions without or very large separator/spacer count limits

•  ParseString2List Functions exactly the same as llParseString2List and llParseStringKeepNulls.
•  separateWords Functions the same as llParseString2List unless certain preconditions are not met.

See Also

Functions

•  llParseString2List
•  llDumpList2String
•  llCSV2List
•  llList2CSV

Deep Notes

Search JIRA for related Issues

Signature

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