Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic reference not working on For Each loop..
Message
De
08/04/2011 11:39:28
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Dynamic reference not working on For Each loop..
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01506642
Message ID:
01506642
Vues:
128
Any idea why VFP doesn’t like this attempt to eval a local string var into an object reference:
Lparameters tcField, tcValue

Local lcContainer

lcContainer = 'Thisform.Container1.container' + tcField + '.Controls'

For each loControl in &lcContainer
	If Upper(control.baseclass) = 'CHECKBOX' and Upper(tcValue) $ Upper(loControl.caption)
		loControl.value = 0
		loControl.enabled = .f.
	EndIf
EndFor
It gives a "Nesting Error" messagebox *AT THE END* of the first pass through the loop. I can see in the debugger that “control” has been resolved as the first item in the collection of Controls and that it has made it to the EndFor line when the error message appears.

Why does it choke out with this syntax?


If I wrap in in parentheses it works fine:
For each control in (lcContainer)
  ...
EndFor
What's the difference here in () vs. &


.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform