Hi Jennifer,
>
> Can anyone tell me why this isn't working. I can't stare at this any
> longer. The output runs fine until there is a CYOriginal = 0. Blows up.
> Help, Please.
>
> <CFOUTPUT>#IIF(CYOriginal EQ 0, IIF(Requested GT 0, DE("100.0"),
> DE("0.0")),
> NumberFormt(100*Change/CYOriginal, '__._'))#</CFOUTPUT>
>
All the parameters of IIF are evaluated at the time that it is processed.
If CYOriginal is zero then the "false" parameter will try to evaluate
100*Change/0, which is giving you the "division by zero" error.
The true and false parameters of IIF must be string expressions and not
numeric calculations.
I'm afraid that you'll have to use CFIF to generate the correct output.
<cfif CYOriginal EQ 0>
<cfset CYOutput = IIF(Requested GT 0, DE('100.0'), DE('0.0'))>
<cfelse>
<cfset CYOutput = NumberFormat(100*Change/CYOriginal,'____._')>
</cfif>
<cfoutput>#CYOutput#</cfoutput>
Bear in mind that your NumberFormat mask needs to be big enough to cope with
your number. I tested this with a mask of __._ and Change = 5 and
CYOriginal set to 2. The answer is 250, but this was causing an error
because the mask was only beg enough for 2 digits and not 3.
Regards
Stephen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists