CFLib.org – Common Function Library Project

nullFormat(expression)

Last updated April 07, 2006

author

Mike Tangorre

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
I use this in tags such as cfqueryparam when I need to determine if an expression evaluates to true or false. While this is certainly NOT needed as you can use YesNoFormat and plain old # signs with the expression between, it does make the intent more clear.

Return Values:
Returns a boolean.

Example:

<cfoutput>

<cfset q = -9 />
<cfset r = 1 />
<cfset x = 5 />
<cfset y = 2 />
<cfset z = 0 />
#nullFormat(x gt y)#<br> 
#nullFormat(x lt y)#<br>
#nullFormat(x eq y)#<br>
#nullFormat(x)#<br>
#nullFormat(y)#<br>
#nullFormat(z)#<br>
#nullFormat(q)#<br>
#nullFormat(r)#<br>
#nullFormat(x * z + y)#

</cfoutput>

Parameters:

Name Description Required
expression Expression to evaluate. Yes

Full UDF Source:

/**
 * A convenience function to determine if an expression evaluates to true or false.
 * 
 * @param expression      Expression to evaluate. (Required)
 * @return Returns a boolean. 
 * @author Mike Tangorre (mtangorre@cfcoder.com) 
 * @version 1, April 7, 2006 
 */
function nullFormat(expression) {
   if (expression) return true;
   return false;
}

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