There's a distinct difference in how the two types of loops operate. CFLOOP compiles 
the entire loop set into one operation and does it. Think of it like lego blocks with 
each block being a single loop iteration. All of the blocks are stacked together 
before it starts (assuming a from/to look). The CFSCRIPT for loop does an iteration at 
a time with a check between each. Think of it as a pile of legos with each iteration 
adding another lego to the stack. This means that the CFLOOP is a bit more efficient. 
Additionally, to output the data you need to use a CFOUTPUT or a Writeoutput(). Of the 
two, CFOUTPUT is the more efficient (there's an article on it in the archives.) I'd 
say use the CFLOOP unless the query happens to be in the middle of a CFSCRIPT block. 
In that case, use the CFSCRIPT 
version for cleanliness. The speed difference will be minimal on CF5.

At 07:07 AM 3/26/02, you wrote:
>>From an earlier question on CF-Talk .....
>
>Someone wanted to loop through a recordset within a CFSCRIPT block, so from
>our esteemed listmaster's docs
>(http://www.houseoffusion.com/docs/cfscript.htm) we have this example (great
>stuff by the way):
>
><CFSCRIPT>
>     For (i=1;i LTE Queryname.Recordcount; i=i+1)
>          writeoutput(Queryname.Record[i]&'<BR>');
></CFSCRIPT>
>
>In regular CF:
>
><cfloop query="queryName">
>   <cfoutput>#Record#<br></cfoutput>
></cfloop>
>
>Which is better? Should I use CFSCRIPT for looping through and displaying
>complicated data tables or continue with regular CFOUTPUT?
>
>
>Erika
>(with a *K*)
>
>"Life...  is like a grapefruit.  It's orange and squishy,
>and has a few pips in it, and some folks have half a one for breakfast."
>-----------------------------------------------------
>Erika L. Walker-Arnold, VP, RUWebby, LLC
>-----------------------------------------------------
>Macromedia ColdFusion Alliance Partner
>Macromedia ColdFusion 5.0 Certified Developer
>-----------------------------------------------------
>
>
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to