Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: With Collections or FOR EACH...
Message
De
23/10/2003 10:25:48
 
 
À
23/10/2003 08:41:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00841263
Message ID:
00841558
Vues:
20
>>Hi,
>>>
>>
>>        FOR EACH loForm IN THIS.FormList
>>            IF UPPER(loForm.NAME) == tcName AND UPPER(loForm.BASECLASS) = 'FORM'
>>                llFound = .T.
>>                *!* BAM! As soon as the next line executes,
>>                *!* loForm is no longer an object!
>>                EXIT
>>            ENDIF
>>        ENDFOR
>>
>>>
>>
>>Am I missing something - I wouldn't expect loForm to be in scope outside of the FOR EACH - ENDFOR construct..
>>
>
>Why not? It's just a variable, either local (if defined) or private. I use constructions like this a lot to find things in collections.

Not arguing your conclusion, Tamar. But I do want to point out that in my opinion the VFP Help's FOR...EACH is poorly documented as regards the "var" part of the command.
It uses "var" as the object of the iteration (allowing the array or object collection ("Group") as being the subject) and simply describes it as "A variable or array element used to iterate through the elements of Group.". The 'workings' of this are very unintuitive, at least to me, and the meagre explanation is of no help whatsoever. When I first encountered it I found myself saying 'what the heck is 'var'?.... Where does 'var' come from?... What relationship does 'var' have with anything else?'. From the example I was able to see how to use it but I still had mistrust of what 'var' actually was and how I could use it.

Fortunately the Hacker's Guide did a much better job of explaining the thing.

cheers

>
>Tamar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform