Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
Les118 #1
Inconsistent Syntax Rules - Numbers
First piece of business: We are running CF 7.0.1 with hotfix hf70161212
applied. Now for the problem.
There is a piece of code in one of our programs that looks like this:
<cfif RDS_TOTAL GT 98.9 >
<cfset RDS_TOTAL_CALC = 4>
<cfelseif RDS_TOTAL GTE 97.5 AND RDS_TOTAL LTE 98.9>
<cfset RDS_TOTAL_CALC = 3>
<cfelseif RDS_TOTAL GTE 90 AND RDS_TOTAL LTE 97.4>
<cfset RDS_TOTAL_CALC = 2>
<cfelseif RDS_TOTAL GTE 85 AND RDS_TOTAL LTE 89.9>
and so on....
We had a rds_total value of 97.5 that was recognized by the above code and
rds_total_calc was set to 3. When the rds_total was 97.4 the rds_total_calc
was not set and the program failed.
The resolution to the problem was to re-code the one line of
<cfelseif RDS_TOTAL GTE 90 AND RDS_TOTAL LTE 97.4>
to:
<cfelseif #numberformat(RDS_TOTAL, "999.9")# GTE 90.0 AND
#numberformat(RDS_TOTAL, "999.9")# LTE 97.4>
With that modification the program recognized 97.4, rds_total_calc was set to
2, and the program updated the record successfully.
Please help me understand why this one line had to be re-coded. Is there a
bug in CF 7? Thanks.
Les118 Guest
-
3D export 'rules'
Where would I find a complete set of 'rules' or guildelines for exporting from 3D Max to sw3d? I know tehre are a few technotes at Adobe like:... -
NAT rules in ppp
This is the rule i presently have in my ppp.conf file nat port tcp 10.100.6.10:6881-6999 6881-6999 What im wanting to change without the need... -
MWM logo rules
Hello, even if this topic has been discussed before in this group, I'm still confused. I'm about to finish a commercial Director project. As far... -
paragraph rules
i'm using freehand 9 - is it possible to set paragraph rules , and er how? like this: (obviously i could draw my own lines between each text line... -
Message Rules
I have Windows XP Pro and am using Microsoft Outlook Express for my e-mail. I set my "Message Rules" to delete any mail which contains certain... -
Dan Bracuk #2
Re: Inconsistent Syntax Rules - Numbers
I don't know the answer, but, I would test this line for sure:
<cfelseif RDS_TOTAL GTE 85 AND RDS_TOTAL LTE 89.9>
You might have the same problem.
also, adding .0 to the first number would probably be just as effective as
what you did, and less work.
Dan Bracuk Guest
-
Les118 #3
Re: Inconsistent Syntax Rules - Numbers
Thanks for the response. Yes, we had the same idea and added the .0 to the first number and it still failed.
Les118 Guest
-
mxstu #4
Re: Inconsistent Syntax Rules - Numbers
It also worked fine for me with MX7
<cfset RDS_TOTAL = "97.4">
<cfif RDS_TOTAL GT 98.9 >
<cfset RDS_TOTAL_CALC = 4>
<cfelseif RDS_TOTAL GTE 97.5 AND RDS_TOTAL LTE 98.9>
<cfset RDS_TOTAL_CALC = 3>
<cfelseif RDS_TOTAL GTE 90 AND RDS_TOTAL LTE 97.4>
<cfset RDS_TOTAL_CALC = 2>
<cfelseif RDS_TOTAL GTE 85 AND RDS_TOTAL LTE 89.9>
<cfset RDS_TOTAL_CALC = 1>
<cfelse>
<cfset RDS_TOTAL_CALC = 1>
</cfif>
<cfoutput>
RDS_TOTAL = #RDS_TOTAL#<br>
RDS_TOTAL_CALC = #RDS_TOTAL_CALC#<br>
</cfoutput>
mxstu Guest
-
JMGibson3 #5
Re: Inconsistent Syntax Rules - Numbers
Is RDS_TOTAL_CALC the result of a calculation in CF or is it straight out of a
database with precision set to exactly one decimal? The latter should work
forever. The former or a DB definition that results in float could often fail.
Calculation results (esp now with a Java backbone) may often be rendered
internaly as float and actually carry extra decimals. With CF's loose type
casting you never know for sure whether you're comparing apples to apples or
oranges. That's why the explicit Numberformat solved your problem, you wound
up with apples and apples. Actually the structure never really covered all the
bases. It left out values between 97.5 and 97.4 (whether or not they were
expected, they still wern't covered).
On general principles you should have been coded: RDS_TOTAL GTE 90 AND
RDS_TOTAL LT 97.5, ie less than the prio boundary not less than or equal to a
different boundary. As to why it worked before, what CF version were you? I'd
suspect that version used the literal operands to construct a temporary
NumberFormat on your behalf, esp if your version was pre-Java (5.0 I believe,
I'm stuck on 4.5 seemingly forever now)
JMGibson3 Guest



Reply With Quote

