Difference between revisions of "LlDumpList2String"

From Second Life Wiki
Jump to navigation Jump to search
m (Added some further explanation)
Line 13: Line 13:
|examples=
|examples=
<lsl>list mylist = ["a", "b", "c", "d"];
<lsl>list mylist = ["a", "b", "c", "d"];
string tmp = llDumpList2String(mylist, " ** ");
string tmp = llDumpList2String(mylist, "**");
//tmp now equals: "a**b**c**d"</lsl>
//tmp now equals: "a**b**c**d"</lsl>


Line 23: Line 23:
     state_entry(){
     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,"><") + ">");  
//says: "<1><2.000000><a string><a822ff2b-ff02-461d-b45d-dcd10a2de0c2>"        
     }
     }
}</lsl>
}</lsl>

Revision as of 02:08, 23 July 2009

Summary

Function: string llDumpList2String( list src, string separator );
0.0 Forced Delay
10.0 Energy

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

• list src
• string separator

Use llParseString2List or llParseStringKeepNulls to undo the process.

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

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

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

<lsl>default{

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

//says: "<1><2.000000><a string><a822ff2b-ff02-461d-b45d-dcd10a2de0c2>"

   }
}</lsl>

Notes

Instead of using <lsl>llDumpList2String(myList, "")</lsl> you should use <lsl>(string)myList</lsl>

Deep Notes

Signature

function string llDumpList2String( list src, string separator );