The LEAST no of "CFIF" is the route to best code/speed etc.. This is my theory though Using CFSCRIPT blocks, short-cut evaluation, Switch statements wherever possible than CFIF, arranging likely executable CFIF's/Switch first etc
Would be cleaner code to seperate Application Logic from Presentation layer. eg qry_studentStatus.cfm (Query) dsp_studentStatus.cfm(Display) Use of CFoutput's only where necessary is faster than wraping it around entire HTML etc. Joe Certified Advanced ColdFusion Developer [EMAIL PROTECTED] -----Original Message----- From: Adams, Stephen [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 16, 2002 5:09 AM To: CF-Talk Subject: Writing efficient CFIF statements ********************************************************************** WESTMINSTER CITY COUNCIL Please refer to the disclaimer beneath this message ********************************************************************** Hi, I am trying to put more structure into my CF code. My idea is to separate the ColdFusion processing from the HTML structure and use CSS for the look of the site. I am trying to get an idea of what is the best way to separate the CF. I know that I could use custom tags, user defined function and if I was using MX, then components. But these are for code that can across used in multiple pages. What I am talking about is the CF for an individual page. What has all this to do with CFIF statements, well. I was thinking of setting a series of flags that are checked against in my HTML. The CFIF statements are there to check the value of these flags and amend the page depending on these flags. So I want to be able to write good efficient CFIF statements so that my code is up to speed. Here's an example of what I am talking about: <!--- Default ColdFusion Parameters ---> <cfparam name="QueryResults" default="" type="string"> <!--- ColdFusion Processing ---> <cfquery name="myQuery" datasource="myDSN"> SELECT * FROM myTable </cfquery> <!--- Sets flags ---> <cfif myQuery.RecordCount EQ 0> <cfset QueryResults = 1> </cfif> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <cfif QueryResults EQ "1"> <table cellspacing="2" cellpadding="2"> <tr> <td class="mainFont">Results found.</td> </tr> </table> <cfelse> <table cellspacing="2" cellpadding="2"> <tr> <td class="mainFont">No results found.</td> </tr> </table> </cfif> </body> </html> This is a simple example, but it shows how I want to keep the processing separate at the top of the page. My question, finally, is how are CFIF statements best written if I want to code this way and or is there a better way of writing my CF code. Thanks. ********************************************************************** Westminster City Council switchboard: +44 20 7641 6000 ********************************************************************** This E-Mail may contain information which is privileged, confidential and protected from disclosure. If you are not the intended recipient of this E-mail or any part of it, please telephone Westminster City Council immediately on receipt. You should not disclose the contents to any other person or take copies. ********************************************************************** ______________________________________________________________________ Get the mailserver that powers this list at http://www.coolfusion.com FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists