ColdFusion UDF Library - listExclude

December 16th, 2008
«« Back to ColdFusion Library

Category:
   LIST

Description:
   Loops through xList removing any occurances in list.

Parameters:
  1. list (List, required)
           The list to perform the operation on.

  2. xList (List, required)
           The list of elements to exclude from the list.

  3. delimiter (String, Default: ,)
           The delimiter to use for the list.

  4. xDelimiter (String, Default: ,)
           The delimiter to use for the exclusion list.


Returns:
       (List) The list with the specified elements removed.

Requires:
       

Sample Use:
       

Copy to Clipboard
function listExclude(list,xList){
	var loop = 0;
	var loop2 = 0;
	var pos = 0;
	var count = 0;
	var delimiter = ",";
	var xDelimiter = ",";
	var item = "";
	if (arrayLen(arguments) gte 3)delimiter = arguments[3];
	if (arrayLen(arguments) gte 4)xDelimiter = arguments[4];
	for (loop = 1; loop lte listLen(xList,xDelimiter); loop = incrementValue(loop)){
		item = listGetAt(xList,loop);
		count = listValueCountNoCase(list,item,delimiter);
		for (loop2 = 1; loop2 lte count; loop2 = incrementValue(loop2)){
			pos = listFindNoCase(list,item,delimiter);
			if (pos)list = listDeleteAt(list,pos,delimiter);
		};
	};
	return list;
}
// http://www.programmers.org/index.php/coldfusion-udf-library/?ckey=310&function=listExclude
  1. No comments yet.
  1. No trackbacks yet.