Bug Reports / Problem with "break" and nested for loops |
| Author | Message | ||
|
C0wbox
User ![]() Joined: Tue Jun 6th 2006 Location: 0,125,-250 |
Where INDEX2-1 is the last entry into the array TREES and we start with TREES.ACTIVE from 0 to INDEX2-1 all equal to 1. + Code Snippet The problem is that where it should find the first 1 in the array and replace it with 0, it locates them all and replaces them all with 0 because it never breaks from the loop. I know this to be true because when the main outer for-loop is run once and there are say, 150 TREES entries, all the TREES().ACTIVEs are changed to 0. This isn't the first place I've encountered this problem. But with this project it is more of a nuisance than where I first encountered it. For the time being I have had to make do with a while-loop, which works, but I'm not very happy about using. + Code Snippet |
||
| Back to top |
|||
|
Benjamin
User Joined: Sun Nov 24th 2002 Location: France |
I'm pretty sure the command you want is exit. |
||
| Back to top |
|||
|
C0wbox
User ![]() Joined: Tue Jun 6th 2006 Location: 0,125,-250 |
|
||
| Back to top |
|||
|
Google Ad
AdBot Joined: Aug 26th 2002 Location: Everywhere |
|||
| Back to top |
|||
|
Benjamin
User Joined: Sun Nov 24th 2002 Location: France |
I think it breaks to the debugger however I don't have the documentation in front of me so I can't see right now. |
||
| Back to top |
|||
|
C0wbox
User ![]() Joined: Tue Jun 6th 2006 Location: 0,125,-250 |
|
||
| Back to top |
|||
|
Green Gandalf
Valued Member ![]() Joined: Mon Jan 3rd 2005 Location: Cornwall UK |
COwbox Quote: "I thought exit only worked for do-loops, repeat-loops and while-loops?"
I sympathise with you. This is what the Help file says: Quote: "Only control loops that have an uncertain exit condition can use this command such as DO LOOP, WHILE and REPEAT loops. EXIT will have no effect on GOTO loops during the running of your program."
I wasn't aware the DO LOOP had any built-in exit condition uncertain or otherwise. I, like you, would have assumed that the Help file means that you can't use exit from a for next loop (which usually doesn't have an uncertain end condition from the programmer's point of view) and often make the same mistake till I remember. You can use exit of course. I really think someone should write those files in plain English - or German, French, Chinese, etc. We all have access to Google translator after all. Just one standard language would be enough. |
||
| Back to top |
|||
|
C0wbox
User ![]() Joined: Tue Jun 6th 2006 Location: 0,125,-250 |
|
||
| Back to top |
|||
You must be logged-in to post messages to this forum. You can register an account for free. Or click here to login.
Forum Search
Enter a word or phrase to search our Forum for:
|
|





