CFLib.org – Common Function Library Project

nullFormat(expression)

Last updated April 7, 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;
}
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