Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exit nested FOR loops
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01244106
Message ID:
01244204
Vues:
18
Good point. In other words, we still may need this check and exit right after the NEXT statement of the inner loop.

>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
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform