CFLib.org – Common Function Library Project

IsSafeArray(arr)

Last updated April 29, 2002

author

Raymond Camden

Version: 1 | Requires: CF6 | Library: DataManipulationLib

Description:
Returns true if all positions in an array are defined.

Return Values:
Returns a boolean.

Example:

<cfscript>
a = arrayNew(1);
a[1] = "d";
a[2] = "e";
a[4] = "f";
writeOutput("Is a complete? " & IsSafeArray(a));
</cfscript>

Parameters:

Name Description Required
arr The array to check. Yes

Full UDF Source:

/**
 * Returns true if all positions in an array are defined.
 * 
 * @param arr 	 The array to check. (Required)
 * @return Returns a boolean. 
 * @author Raymond Camden (ray@camdenfamily.com) 
 * @version 1, April 29, 2002 
 */
function IsSafeArray(arr) {
	var i=1;
	var temp = "";
	
	for(i=1; i lte arrayLen(arr); i=i+1) {
		try {
			temp = arr[i];
		} catch(coldfusion.runtime.UndefinedElementException ex) {
			return false;
		}		
	}
	
	return true;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson