Copy link to clipboard
Copied
Good morning all,
I am having a problem with this formula. <cfset FORM.UnitsProd = FORM.EndUnits - (FORM.StartUnits) + 1 >
When FORM.StartUnits = 1 then, my calculations are wrong. For instance, EndUnits and StartUnits represent serial numbers, which I can then, total as UnitsProd. If EndUnits = 3 and StartUnits = 1; I get 3 = 3-1+1. But, 15 = 60 - 46 +1. Would a cfif statement resolve this?
<cfset FORM.UnitsProd = FORM.EndUnits - (FORM.StartUnits) + 1 >
<cfif>
#FORM.StartUnits# = 1
<cfelse>
<cfset FORM.UnitsProd = FORM.EndUnits + FORM.StartUnits >
</cfif>
Does this make sense?
Thanks in advance,
DJ Khalif
Copy link to clipboard
Copied
Does it make sense? Not to me.
Maybe if you show us some numbers that include what you think the answer should be and what it actually is, it would more clear.
Copy link to clipboard
Copied
Dan,
UnitsProd = EndUnits - StartUnits + 1, (3 = 3 - 1 + 1). This should be 4
But,
UnitsProd =EndUnits - StartUnits +1, (15 = 60 - 46 +1) This is correct.
I hope this helps.
Thanks,
DJ Khalif
Copy link to clipboard
Copied
"UnitsProd = EndUnits - StartUnits + 1, (3 = 3 - 1 + 1). This should be 4"
I think you need to take your calculator back to the store - that's correct, it should be (and is) 3.
3 - 1 = 2
2 + 1 = 3
Or, to make it simpler, the "- 1" and "+ 1" cancel each other out, so it becomes:
3 = 3
Your app is running correctly, it's your verification calculations which are wrong.
Copy link to clipboard
Copied
Phil,
Thanks for the jab. However, I spoke too soon. As ugly as it looks it does work. I went back to look at the results and realized that; if I produced 1 unit then, my formula works properly. That's the basis for the whole thing. To put it plainly, I was trying solve what I solved.
Thanks,
DJ Khalif