Difference between revisions of "User:SignpostMarv Martin/LSL2/csv ampersandise"
Jump to navigation
Jump to search
(dumping trivial function on the wiki) |
m |
||
Line 1: | Line 1: | ||
<lsl>/** | |||
/* @package LSL | /* @package LSL | ||
/* @subpackage strings | /* @subpackage strings | ||
Line 40: | Line 40: | ||
} | } | ||
} | } | ||
</lsl | </lsl> | ||
[[Category:LSL Library|random:location]] | [[Category:LSL Library|random:location]] |
Revision as of 07:03, 16 April 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>