I meant assume TRUE to start of course
.:.:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com http://cf4em.com -----Original Message----- From: Bobby Hartsfield [mailto:[email protected]] Sent: Friday, July 08, 2011 5:05 PM To: cf-talk Subject: RE: dynamic if statements Since they are all Booleans (judging from the way you referenced them) only one of them has to be false for the whole if to fail. So, assume false to start, then loop over each item until you either reach the end or one is false. Example... you have a, b, and c <cfset a = true /> <cfset b = true /> <cfset c = true /> <cfset validate = true /> <cfloop list="a,b,c" index="i"> <cfif !variables[i]> <cfset validate = false /> <cfbreak /> </cfif> </cfloop> <cfif validate> Do whatever because all variables were true <cfelse> Don't process because one or more variables was false </cfif> Running that should Result in "Do whatever because all were true" If you change any of the A, B or C vars to false at the top, the result should be "Don't process because one or more variables was false" If you wont know the a,b,c variables, then Id do what I could to put them into a unique structure then loop over that structure... For example... <cfset varStruct = {} /> <cfset varStruct['a'] = true /> <cfset varStruct['b'] = true /> <cfset varStruct['c'] = true /> <cfset validate = true /> <cfloop collection="#varStruct#" item="i"> <cfif !varStruct[i]> <cfset validate = false /> <cfbreak /> </cfif> </cfloop> <cfif validate> Do whatever because all variables were true <cfelse> Don't process because one or more variables was false </cfif> .:.:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com http://cf4em.com -----Original Message----- From: Richard White [mailto:[email protected]] Sent: Friday, July 08, 2011 12:03 PM To: cf-talk Subject: Re: dynamic if statements thanks bobby, yes i am also noticing evaluate runs slow as the processing increases. i like your example although how would i write the code if sometimes there are 3 variables, sometimes 4 etc... it almost seems to me there needs to be a loop inside the if statement, unless i am misunderstanding this? thanks >This might work as well (and get rid of evaluate for you) > ><cfif variables[a] eq variables[b]> > > >.:.:.:.:.:.:.:.:.:.:.:.:.:. >Bobby Hartsfield >http://acoderslife.com >http://cf4em.com > > >apologies, the evaluate works fine, there was a mistake in my code :) > >i was unnecessarily wrapping the variables with hashes: <cfif evaluate("#a# >eq #b#")></cfif> > > > >... >> it then throws an error due to the double quote being encapsulated >> within the double quotes of the evaluation function. >> >> would appreciate some help on the best way to achieve this >> >> thanks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346167 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

