User:SignpostMarv Martin/LSL2/csv ampersandise
< User:SignpostMarv Martin
Jump to navigation
Jump to search
Revision as of 21:17, 5 April 2009 by SignpostMarv Martin (talk | contribs) (dumping trivial function on the wiki)
<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>