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

JUstin

>-----Original Message-----
>From: Ruslan Sivak [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, January 17, 2001 3:12 PM
>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