394
IsDefined
Evaluates a string value to determine if the variable named in the string value exists.
IsDefined returns TRUE if the specified variable is found, FALSE if not found.
IsDefined provides an alternative to the ParameterExists function, eliminating the
need for cumbersome expressions used to test for the existence of a variable:
Evaluate("ParameterExists(#var_name#)")
See also Evaluate.
Syntax
IsDefined(" variable_name ")
variable_name
A string value, the name of the variable you want to test for. This value must
always be enclosed in quotation marks.
Example
<!--- This example shows the use of IsDefined --->
<HTML>
<HEAD>
<TITLE>
IsDefined Example
</TITLE>
</HEAD>
<BODY BGCOLOR=silver>
<H3>IsDefined Example</H3>
<CFIF IsDefined("FORM.myString")>
<P>Because the variable FORM.myString has been defined, we
can now show its contents.
and its resulting action template in the same template, while using
IsDefined to control the flow of template execution.
<P>The value of "FORM.myString" is <B><I><CFOUTPUT>#FORM.myString#
</CFOUTPUT></I></B>
<CFELSE>
<P>During the first time through this template, the variable
"FORM.myString" has not yet been defined, so it is not evaluated.
</CFIF>
...
</BODY>
</HTML>
This construction allows us to place a FORM
CFML Language Reference