CFLib.org – Common Function Library Project

CFParam(varname [, value])

Last updated November 13, 2001

Version: 2 | Requires: ColdFusion 5 | Library: UtilityLib

 
Rated 2 time(s). Average Rating: 3.0

Description:
Allows you to cfparam variables from within cfscript.

Return Values:
Returns the value of the variable parammed.

Example:

view plain print about
<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:

view plain print about
<cfscript>
/**
 * 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);
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
3 day(s) ago

Will Belden Will Belden added
longTime
9 day(s) ago

James Sleeman James Sleeman added
quickSort
19 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
22 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson