ArrayDefinedAt(arr, pos)
Last updated October 24, 2003
Version: 2 | Requires: ColdFusion MX | Library: DataManipulationLib
Description:
Returns true if a specified array position is defined.
Return Values:
Returns a boolean.
Example:
a = arrayNew(1);
a[1] = "d";
a[2] = "e";
a[4] = "f";
for(i = 1; i lte arrayLen(a); i=i+1) {
if(arrayDefinedAt(a,i)) writeOutput("a#i# is #a[i]#<br>");
else writeOutput("a#i# is undefined<br>");
}
</cfscript>
Parameters:
| Name | Description | Required |
|---|---|---|
| arr | The array to check. | Yes |
| pos | The position to check. | Yes |
Full UDF Source:
<cfscript>
/**
* Returns true if a specified array position is defined.
*
* @param arr The array to check. (Required)
* @param pos The position to check. (Required)
* @return Returns a boolean.
* @author Raymond Camden (ray@camdenfamily.com)
* @version 2, October 24, 2003
*/
function arrayDefinedAt(arr,pos) {
var temp = "";
try {
temp = arr[pos];
return true;
}
catch(coldfusion.runtime.UndefinedElementException ex) {
return false;
}
catch(coldfusion.runtime.CfJspPage$ArrayBoundException ex) {
return false;
}
}
</cfscript>
Search CFLib.org
Latest Additions
Shawn Porter added
DeMoronize
3 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)