Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exit nested FOR loops
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01244106
Message ID:
01244199
Views:
21
Naomi,

>Just set both counters to maximum number and you will fall off the loops.

That'll not always work, you'll need a test after each loop sometimes, your method will only work if there are no commands after the inner loop(s), like
for lnOuterLoop = 1 to lnMaxOuterLoops
	for lnInnerLoop = 1 to lnMaxInnerLoops
		* Do Something
		if SomeCondition()
			lnOuterLoops	= lnMaxOuterLoops + 1
			exit
		endif
	next lnInnerLoop
	* Now, if you are ending the loop here, you do not need further tests, but if you have some commands....
	if lnOuterLoop > lnMaxOuterLoops
		exit
	endif
	* Your extra commands
next lnOuterLoop
So, basically, your solution and Hilmar's are similar, you could've use a flag instead of changing the iteration variable, which might not be as clear and I do not like too much to fiddle with this controller variables, just in case
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform