Difference between revisions of "LlParseStringKeepNulls"

From Second Life Wiki
Jump to navigation Jump to search
m (match caveats stated here to the caveats stated at llParseString2List)
Line 6: Line 6:
|func_id=285|func_sleep=0.0|func_energy=10.0
|func_id=285|func_sleep=0.0|func_energy=10.0
|func=llParseStringKeepNulls|return_type=list|p1_type=string|p1_name=src|p2_type=list|p2_name=separators|p3_type=list|p3_name=spacers
|func=llParseStringKeepNulls|return_type=list|p1_type=string|p1_name=src|p2_type=list|p2_name=separators|p3_type=list|p3_name=spacers
|func_footnote='''separators''' and '''spacers''' must be lists of strings, maximum of 8 each.
|func_footnote
|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
|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.
|caveats=* Never provide more than 8 separators, never provide more than 8 spacers.
** ''integer my_int = (integer)llList2String(my_list,i);''
* Provide lists of strings as the separators and spacers, not mixed lists of strings and floats and such.
*** [[llList2String]] is used here, as [[llList2Integer]] can only handle integers in simple notation, ie. will not handle hexadecimal integers or scientific notation.  
* Don't let any spacer contain or equal a separator, and don't let any separator contain or equal a spacer.
* Do list each spacer and separator only once.
* 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.
|constants
|constants
|examples=<pre>default
|examples=<pre>default
Line 33: Line 35:
'''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 the same as [[llParseString2List]] except in specific instances of overlaps between spacers and separators}}
{{LSL DefineRow||[[Separate Words|separateWords]]|Functions exactly the same as [[llParseString2List]] unless you violate the preconditions.
Also correct at a glance.}}
{{!}}}
{{!}}}
|also_functions=*{{LSLG|llParseString2List}}
|also_functions=*{{LSLG|llParseString2List}}

Revision as of 03:41, 2 October 2007

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

Caveats

  • Never provide more than 8 separators, never provide more than 8 spacers.
  • Provide lists of strings as the separators and spacers, not mixed lists of strings and floats and such.
  • Don't let any spacer contain or equal a separator, and don't let any separator contain or equal a spacer.
  • Do list each spacer and separator only once.
  • 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 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

Replacement functions without or very large separator/spacer count limits

•  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.

Deep Notes

Search JIRA for related Issues

Signature

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