Difference between revisions of "User:SignpostMarv Martin/LSL2/csv ampersandise"
Jump to navigation
Jump to search
m |
m |
||
Line 41: | Line 41: | ||
} | } | ||
</lsl> | </lsl> | ||
[[Category:LSL Library| | [[Category:LSL Library|csv ampersandise]] |
Revision as of 16:49, 12 May 2009
<lsl>/** /* @package LSL /* @subpackage strings /* @author SignpostMarv Martin /* @license Creative Commons BY-SA UK 2.0 http://creativecommons.org/licenses/by-sa/2.0/uk/ /* trivial function for converting a list to an ampersandised csv ("foo & baz" or "foo, bar & baz" type strings).
- /
/** /* @param list items The list to convert to an ampersandised csv /* @return string an ampersandised csv
- /
string csv_ampersandise(list items) { /**
- Stores the last entry in the list in a variable since it is used in two different places.
- /
string last = llList2String(items,-1);
/**
- Return an empty string if the list is empty
- /
if(llGetListLength(items) == 0) { return ""; }
/**
- return last if it is the only entry in the list.
- /
else if(llGetListLength(items) == 1) { return last; }
/**
- if the list length is 2, output will be along the lines of "foo & bar"
- if the list length is 3 or more, output will be along the lines of "foo, bar & baz"
- /
else { return llDumpList2String(llDeleteSubList(items,-1,-1),", ") + " & " + last; }
} </lsl>