countTrueBoolKeysInStruct(strc)
Last updated September 16, 2012
Version: 1 | Requires: CF8 | Library: UtilityLib
Description:
You supply a structure filled with keys that are boolean values, and I will return a number of how many keys were boolean values that evaluated to true.
Return Values:
Returns a numeric value that is the number of boolean TRUE values found in the struct
Example:
<cfscript>
loc={};
loc.lorem="true";
loc.ipsum="false";
loc.dolor="true";
</cfscript>
result is 2: #countTrueBoolKeysInStruct(loc)#
Parameters:
Name | Description | Required |
---|---|---|
strc | A struct to count positive booleans | Yes |
Full UDF Source:
/**
* I loop through a struct that contains keys set to boolean values and return count of how many keys evaluate true.
* v0.1 by Alan McCollough
* v1.0 by Adam Cameron. VARing
*
* @param strc A struct to count positive booleans (Required)
* @return Returns a numeric value that is the number of boolean TRUE values found in the struct
* @author Alan McCollough (amccollough@anthc.org)
* @version 1.0, September 16, 2012
*/
function countTrueBoolKeysInStruct(strc){
var x = 0;
var i = 0;
for(i in strc) {
if (isBoolean(strc[i]) && strc[i]){
x++;
}
};
return x;
};
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