Currently in Coldfusion the ListLen() function does NOT count empy list elements so a list "a,b,c,,,d" has only 4 elements. The function below counts all elements including empty list elements, so would therefore return 6 in the mentioned example.
//Count all items in a list (including blank values)
function ListItemCountAll(list)
{
tempList = list;
//check occurances in string
while(find(",,",tempList) GT 0)
{
intInsertPoint = find(",,",tempList);
tempList = insert("0", tempList, intInsertPoint);
}
//Check start string
if(Mid(tempList,1,1) IS ",")
{
tempList = tempList & 0;
}
//Check end string
if(Mid(Reverse(tempList),1,1) IS ",")
{
tempList = tempList & 0;
}
intCount = ListLen(tempList);
return intCount;
}
this doesn’t work when there is something like a,b,”c,e”,d. Counts this as 5 rather than 4.