ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 3rd, 2005, 01:11 PM
FALCONSEYE FALCONSEYE is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 377 FALCONSEYE Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 57 m 14 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
Question <cfbreak> question

greetings!

i have the following structure

<cfloop ...> loop1

<cfloop ....> loop2

<cfloop ...> loop3
if...

else
<cfbreak>
</cfloop>
<cfloop ...> loop4
if...

else
<cfbreak>
</cfloop>

</cfloop>
</cfloop>


my question is if the loop3 if condition is not satisfied where the <cfbreak> dumps me? it seems like it terminates all the loops including loop1 and loop2. if i want to terminate only loop3 and continue with the others what do i need to do?
thanks for the help in advance...

Reply With Quote
  #2  
Old January 3rd, 2005, 01:15 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 45 m 53 sec
Reputation Power: 53
I would *think* it should only terminate the current loop and return processing to "loop 2". But I'm not sure, it could also dump you out of the entire loop series.

However, if you are running four nested loops you may well be missing a more optimal solution to your problem. I'm not sure I've ever seen a situation that required four nested loops to solve.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old January 3rd, 2005, 01:24 PM
FALCONSEYE FALCONSEYE is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 377 FALCONSEYE Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 57 m 14 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
for some reason it breaks out from every single loop. is there a way to just terminate the loop3? i wish i had less loops, but i couldn't come up with a better solution

Reply With Quote
  #4  
Old January 3rd, 2005, 01:51 PM
Bastion Bastion is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 181 Bastion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 25 m 11 sec
Reputation Power: 5
From my recollections, I've run embedded loops that broke on a specific condition and it did not stop the outer loops. To test, I just wrote a simple piece of code.

I have 2 loops. The first loop counts from 1 - 10. With each iteration a second, embedded loop counts down from 10 - 1. If the first loop equals 5, the embedded loop breaks. It worked fine--number five didn't run the embedded loop, but every number did.

Here's the code I ran:

<cfloop index="loopCount" from="1" to="10" step="1">
#loopCount# -&nbsp;
<cfloop index="reverseCount" from="10" to="1" step="-1">
<cfif loopCount IS 5><cfbreak></cfif>
#reverseCount#,
</cfloop><br>
</cfloop>

And the results:

1 - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
2 - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
3 - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
4 - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
5 -
6 - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
7 - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
8 - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
9 - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
10 - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,

Reply With Quote
  #5  
Old January 4th, 2005, 03:22 PM
glively glively is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 17 glively User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 51 sec
Reputation Power: 0
cfbreak definitely only breaks out of the current loop. If it's jumping completely out, maybe the structuring of your loops and/or conditions are not correct.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > <cfbreak> question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT