Difference between revisions of "LlDumpList2String"

From Second Life Wiki
Jump to: navigation, search
m (formatted example)
Line 5: Line 5:
 
|func_desc
 
|func_desc
 
|return_text=that is the list '''src''' converted to a string with '''separator''' between the entries.
 
|return_text=that is the list '''src''' converted to a string with '''separator''' between the entries.
|spec
+
|spec=Unlike [[llList2CSV]] , which dumps a list to a comma-separated formatted string with no choice over the separator, llDumpList2String gives you more control. This can be useful if you don't trust commas as a separator because you might be working with data supplied to the script by a user who uses, say, commas as part of a street address.
 
|caveats
 
|caveats
 
|constants
 
|constants
 
|examples=
 
|examples=
<lsl>default
+
 
{
+
 
     state_entry()
+
list mylist = ["a", "b", "c", "d"];<br />
    {
+
string tmp = llDumpList2String(mylist, " ** ");<br />
 +
//tmp now equals: "a**b**c**d"<br />
 +
 
 +
list mylist = [<10,5,7>, 100, "c", "d"];<br />
 +
string tmp = llDumpList2String(mylist, "**");<br />
 +
//tmp now equals: "<10,5,7>**100**c**d"<br />
 +
 +
 
 +
<lsl>
 +
default{
 +
     state_entry(){
 
         list my_list = [1, 2.0, "a string", llGetOwner()];
 
         list my_list = [1, 2.0, "a string", llGetOwner()];
 
         llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");         
 
         llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");         

Revision as of 18:58, 7 July 2008

Summary

Function: string llDumpList2String( list src, string separator );

Returns a string that is the list src converted to a string with separator between the entries.

• list src
• string separator

Specification

Unlike llList2CSV , which dumps a list to a comma-separated formatted string with no choice over the separator, llDumpList2String gives you more control. This can be useful if you don't trust commas as a separator because you might be working with data supplied to the script by a user who uses, say, commas as part of a street address.

Examples

list mylist = ["a", "b", "c", "d"];
string tmp = llDumpList2String(mylist, " ** ");
//tmp now equals: "a**b**c**d"

list mylist = [<10,5,7>, 100, "c", "d"];
string tmp = llDumpList2String(mylist, "**");
//tmp now equals: "<10,5,7>**100**c**d"


<lsl> default{

   state_entry(){
       list my_list = [1, 2.0, "a string", llGetOwner()];
       llOwnerSay("<" + llDumpList2String(my_list,"><") + ">");        
   }
}</lsl>

Notes

Use llParseString2List or llParseStringKeepNulls to undo the process.

Deep Notes

Search JIRA for related Issues

Signature

function string llDumpList2String( list src, string separator );