deepatpaul
Programmer
How can I return the value of a UDF, not as a literal variable's value, but as a placeholder? Example:
<cfscript>
function isUDF(var1)
errorMsg = "";
{
// do conditionl testing for first variable entered
if var1 != 'foo' (errorMsg = "Custom error 1")
else if var1 == 'foo' (errorMsg = "Custom error 2")
}
// If 2nd argument is passed, then check for return error value, otherwise return boolean.
if (arraylen(Arguments) gt 1)
{
"#arguments[2]#" = errorMsg;
return #arguments[2]#;
// return the value of errorMsg passed as #arguments[2]#
} else {
// otherwise, return boolean value
return true;
}
</cfscript>
<cfif not IsUDF(variables.foo,"variables.placeholder")>
#variables.placeholder#
</cfif>
Where the first variable returns a boolean value, and the second returns a text value of a specified error message. Right now, i get an error saying the 2nd variable can't be converted to boolean, but I don't want boolean for it.
<cfscript>
function isUDF(var1)
errorMsg = "";
{
// do conditionl testing for first variable entered
if var1 != 'foo' (errorMsg = "Custom error 1")
else if var1 == 'foo' (errorMsg = "Custom error 2")
}
// If 2nd argument is passed, then check for return error value, otherwise return boolean.
if (arraylen(Arguments) gt 1)
{
"#arguments[2]#" = errorMsg;
return #arguments[2]#;
// return the value of errorMsg passed as #arguments[2]#
} else {
// otherwise, return boolean value
return true;
}
</cfscript>
<cfif not IsUDF(variables.foo,"variables.placeholder")>
#variables.placeholder#
</cfif>
Where the first variable returns a boolean value, and the second returns a text value of a specified error message. Right now, i get an error saying the 2nd variable can't be converted to boolean, but I don't want boolean for it.