Hey Good Asha...One suggestion would be to add "Adobe CF Team" in your signature. Let CF community know that CF India Team is doing good in participating in public Forums....It helps increase their faith in us.
-----Original Message----- From: Asha K S [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 03, 2007 5:54 AM To: CF-Talk Subject: RE: Next lowest number from array (or list). Another solution could be Here value would be input from the user. <cfset l="32,48,64,72,144,160,200,288,320,400,512,576,640,720,800"> <cfset len=#ListLen(l)#> <cfif #value# LT 32> <cfset res=32> <cfelseif #value# GT 800> <cfset res=800> <cfelse> <cfloop index="i" from="1" to="#len-1#"> <cfset k=ListGetAt(l,i)> <cfset q=ListGetAt(l,i+1)> <cfif #value# GT #k# AND #value# LT #q#> <cfset res=#k#> <cfelseif #value# EQ #k#> <cfset res=#k#> <cfelseif #value# EQ #q#> <cfset res=#q#> <cfelse> </cfif> </cfloop> </cfif> <cfoutput>#res#</cfoutput> Thanks, Asha. -----Original Message----- From: William Seiter [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 03, 2007 1:04 PM To: CF-Talk Subject: RE: Next lowest number from array (or list). Depending on deployment and expected usage, I would suggest adding an 'if' statement around the loop to Dale's code in order to check if the arguments.value is greater than 32. This will reduce the 'if' statement inside the loop to only 1 value check, allowing for a cfbreak to be added as an 'else' statement. <cfif arguments.value gt local.return> <cfloop index="local.index" list="#arguments.list#"> <cfif local.index lt arguments.value> <cfset local.return = local.index /> <cfelse> <cfbreak> </cfif> </cfloop> </cfif> This will allow the function to not perform the loop in the case of the default value of local.return being the only 'true' value to return. It will also allow the loop to stop running the moment a 'true' value is found. In a small deployment, this won't mean a thing, but in a large scale deployment anticipating a lot of use, the milliseconds saved can be valuable. Just my 2 cents William -- William E. Seiter Have you ever read a book that changed your life? Go to: www.winninginthemargins.com Enter passkey: goldengrove -----Original Message----- From: Dale Fraser [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 02, 2007 10:09 PM To: CF-Talk Subject: RE: Next lowest number from array (or list). <cfset myList = "32,48,64,72,144,160,200,288,320,400,512,576,640,720,800"> <cfoutput>#getNextLowest(myList, 12)#</cfoutput> <cffunction name="getNextLowest" returntype="numeric"> <cfargument name="list" type="string" required="true" /> <cfargument name="value" type="numeric" required="true" /> <cfset local = structNew() /> <cfset local.return = 32 /> <cfloop index="local.index" list="#arguments.list#"> <cfif local.index lt arguments.value and local.index gt local.return> <cfset local.return = local.index /> </cfif> </cfloop> <cfreturn local.return /> </cffunction> Regards Dale Fraser http://learncf.com -----Original Message----- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: Wednesday, 3 October 2007 3:20 PM To: CF-Talk Subject: Next lowest number from array (or list). Say that I have a list of allowed nmbers: 32,48,64,72,144,160,200,288,320,400,512,576,640,720,800 If I give the user the option of selecting a number, and it happens to not be in this list, how might I go about automagically selecting the next lowest number? One exception being if the user selects a number lower than 32, in which case the code should return 32. Examples: User selects 100, the code would return 72. User selects 480, the code would return 400. User selects 25, the code would return 32. Currently the numbers are stored in a simple list, but I have control over that list and they can be in whatever format makes the most sense. One caveat is that they need to stay in code (so no database interaction). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Check out the new features and enhancements in the latest product release - download the "What's New PDF" now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290093 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4