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;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson