ColdFusion UDF Library - listMid

December 16th, 2008
«« Back to ColdFusion Library

Category:
   LIST

Description:
   Returns a portion of a list. Similar to how MID() returns a portion of a string.

Parameters:
  1. list (List, required)
           The list you want a section of.

  2. start (Numeric, required)
           The starting postion in the list.

  3. count (Numeric, required)
           The number of elements from (start) you want to reutrn.


Returns:
       (List)

Requires:
       

Sample Use:
       halfMyList = listMid("one,two,three,four", 2, 2);

Copy to Clipboard
function listMid(list,start,count){
	var delimiters = ",";
	var value = "";
	var loop = 0;
	if (arrayLen(arguments) gte 4)delimiters = arguments[4];
	for (loop = start; loop lte (start+count)-1; loop = IncrementValue(loop))value = listAppend(value,listGetAt(list,loop,delimiters),delimiters);
	return value;
}
// http://www.programmers.org/index.php/coldfusion-udf-library/?ckey=37&function=listMid
  1. No comments yet.
  1. No trackbacks yet.