I am not sure what version of CF you are running but you can do what you
want in 4.5.
The other way around it is to use CFPARAM to set it as empty then check it.

eg

<cfparam name="somevar" default="">

<cfif somevar is "something">
 do something
</cfifi>

tim P.

-----Original Message-----
From: Ruslan Sivak [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 17, 2001 10:12 AM
To: CF-Talk
Subject: Short Circuit Evaluation


I have had to write this kind of code over and over, and was wondering if
there is a better way like in c++, where it does lazy evaluation.

This is what I want:

<CFIF isDefined("somevar") AND somevar IS "something">
    do something
</CFIF>

Of course this fails, since if the variable is not defined, CF stil checks
the second condition.  In languages like C++, it did lazy evaluation, so if
the first condition was false, it didn't bother checking the second
condition.  This let people write things like

open(FILE,"file") || die "Can't open file";

So in CF I have to rewrite my above IF statement as 2 statements

<CFIF isDefined("somevar")>
        <CFIF somevar IS "something">
             do something
        </CFIF>
</CFIF>

Is there a better way?

Ruslan Sivak
Technologist
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to