There is no limit, but as you get deeper you have to pay close attention so
that you don't reassign a variable that is being used by a parent loop.
In your case you need to ensure the following:
- that the index of the first loop isn't being manipulated inside any of the
nested loops
- that the condition of the second loop doesn't reference a variable being
changed inside the third loop.
- that the condition of the third loop evaluates to TRUE the first time it
is hit
There is almost never a need to nest loops three deep. The third loop
indicates that your counting something; you can best accomplish this using
SQL (if counting query results) or by utilizing one of CF's many length
functions (arrayLen(), listLen, len(), etc...). Maintaining counters inside
loops is slow in CF and very inefficient. You may want to re-examine the
way your code works...
Bryan Love ACP
[EMAIL PROTECTED]
-----Original Message-----
From: Kevin Gilchrist [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 06, 2001 2:52 PM
To: CF-Talk
Subject: Nested Loop limit?
Hi All,
I've just added some code to my current project that has three-deep nested
loops but the third loop doesn't seem to be processed by CF.
Is there a limit as to how many loops you can nest within each other?
I've been tracing through the code with the debugger and I'm pretty sure it
just skips over the third loop, (causing a nice little infinite loop in the
process too).
Code is of the form
<CFLOOP index type loop>
<CFLOOP condition>
Do stuff
<CFLOOP condition>
increment a counter (this doesn't get touched)
</CFLOOP>
</CFLOOP>
</CFLOOP?
Thanks,
Kevin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists