My idea is this (you wont really find it in a CS tome..
just various peoples opinons on style)


If it makes the code more readable then comapct it.

If nothing is gained by compacting the code... dont do
it unless you comment the code well.

The main thing to watch out for is to make sure your
code stays readable so that when you come back to
it months later you can still understand what you did
(and anyone else who might have the mischance to maintain
code they did not write ;)

Jeremy Allen
elliptIQ Inc.

>-----Original Message-----
>From: Cornillon, Matthieu [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, January 18, 2001 10:12 AM
>To: CF-Talk
>Subject: RE: string to number
>
>
>Steve,
>
>As long as you keep your ranges as you have them in your If statements, the
>following formula should yield the correct result.  I know this doesn't
>address the question that you asked, but others have responded to that, and
>I just couldn't help fiddling.  Hope you don't mind.
>
><CFSET Grp=("form.adult + form.children")>
><CFSET SmRmRq=0>
>
><!--- The \ in this formula is correct. --->
><CFSET SmRmRq=Iif(Grp LTE 28,(Grp-1)\4+1,8)>
>
>Of course, this is harder to modify in the future, should one range change.
>I'm also not sure whether it runs slower or faster.  I am still not sure
>whether my obsession with physically compact code runs counter to good
>programming sense.  I guess I should flip through a CS book!
>
>Matthieu
>
>> -----Original Message-----
>> From: Steve Doran [mailto:[EMAIL PROTECTED]]
>> Sent: Thursday, January 18, 2001 8:36 AM
>> To: CF-Talk
>> Subject: string to number
>>
>>
>> I am trying to get a variable to work that would tell me how
>> many rooms a
>> person would need if they has X amount of people in their party.
>>
>> Here is the Code I am working with:
>>
>> <CFSET Grp=("form.adult + form.children")>
>>
>> <CFSET SmRmRq=0>
>>
>> <CFIF Grp LTE 4>
>>   <CFSET SmRmRq=1>
>> <CFELSEIF (Grp GTE 5) and (Grp LTE 8)>
>>   <CFSET SmRmRq=2>
>> <CFELSEIF (Grp GTE 9) and (Grp LTE 12)>
>>   <CFSET SmRmRq=3>
>> <CFELSEIF (Grp GTE 13) and (Grp LTE 16)>
>>   <CFSET SmRmRq=4>
>> <CFELSEIF (Grp GTE 17) and (Grp LTE 20)>
>>   <CFSET SmRmRq=5>
>> <CFELSEIF (Grp GTE 21) and (Grp LTE 24)>
>>   <CFSET SmRmRq=6>
>> <CFELSEIF (Grp GTE 25) and (Grp LTE 28)>
>>   <CFSET SmRmRq=7>
>> <CFELSEIF Grp GTE 29>
>>   <CFSET SmRmRq=8>
>> </CFIF>
>>
>> The problem I am having is when you output grp it gives you
>> the total of
>> form.adult + form.children.  But when you use grp to set the variable
>> SmRmRq it goes to a string "number + number" and will not accurately
>> convert the variable.
>>
>> Is there a way to change the grp to a number? In Javascript
>> It would be
>> something like Var = (parseInt(form.adult) + parseInt(form.children))
>>
>> Thanks in advance for any assistance,
>>
>> Steve Doran :)
>>
>>
>>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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

Reply via email to