Answered
IIF function
Hi,
I'd be grateful if somebody could please help me out with this problem.
I actually want to write the following using the IIF statement:
<cfif temp gt 0>
<cfset label = "Over">
<cfelseif temp lt 0>
<cfset label = "Under">
<cfelse>
<cfset label = "-">
</cfif>
Note
If I output the variable label using the cfif, cfelseif and cfelse, it gives me the correct output, i.e. either "-", Over, or Under.
I tried the following to rewrite the above statement using the iif function:
<cfset label = iif(temp eq 0,DE("-"),(iif(temp gt 0,DE("Over"),DE("Under"))))>
Now, when temp eq 0, it works fine.
However, when temp is lt 0, it throws me an error message saying variable Under is undefined.
And when temp is gt 0, I get the same error message, but in this case it says variable Over is undefined.
However, if I replace Over and Under by 1 or 0 (i.e. integers) it works perfect!
Any idea how to get the output either Over or Under using the iif statement pls?
Thanks and regards,
Yogesh Mahadnac.
I'd be grateful if somebody could please help me out with this problem.
I actually want to write the following using the IIF statement:
<cfif temp gt 0>
<cfset label = "Over">
<cfelseif temp lt 0>
<cfset label = "Under">
<cfelse>
<cfset label = "-">
</cfif>
Note
If I output the variable label using the cfif, cfelseif and cfelse, it gives me the correct output, i.e. either "-", Over, or Under.
I tried the following to rewrite the above statement using the iif function:
<cfset label = iif(temp eq 0,DE("-"),(iif(temp gt 0,DE("Over"),DE("Under"))))>
Now, when temp eq 0, it works fine.
However, when temp is lt 0, it throws me an error message saying variable Under is undefined.
And when temp is gt 0, I get the same error message, but in this case it says variable Over is undefined.
However, if I replace Over and Under by 1 or 0 (i.e. integers) it works perfect!
Any idea how to get the output either Over or Under using the iif statement pls?
Thanks and regards,
Yogesh Mahadnac.
