CFLib.org – Common Function Library Project

CFParam(varname[, value])

Last updated November 13, 2001

author

Fred T. Sanders

Version: 2 | Requires: CF5 | Library: UtilityLib

Description:
Allows you to cfparam variables from within cfscript.

Return Values:
Returns the value of the variable parammed.

Example:

<CFSET X = 1>
<CFSCRIPT>
cfparam("x","fred");
cfparam("y",2);
</CFSCRIPT>
<CFOUTPUT>
X=#X#, Y=#Y#
</CFOUTPUT>

Parameters:

Name Description Required
varname The name of the variable. Yes
value The default value. If not passed, use No

Full UDF Source:

/**
 * Function to duplicate the <cfparam> tag within CFSCRIPT.
 * Rewritten by RCamden
 * V2 mods by John Farrar
 * 
 * @param varname 	 The name of the variable. 
 * @param value 	 The default value. If not passed, use  
 * @return Returns the value of the variable parammed. 
 * @author Fred T. Sanders (fred@fredsanders.com) 
 * @version 2, November 13, 2001 
 */
function cfparam(varname) {
	var value = "";
	
	if(arrayLen(Arguments) gt 1) value = Arguments[2];
	if(not isDefined(varname)) setVariable(varname,value);
        return evaluate(varname);
}
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