Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dangling reference?
Message
De
20/08/2010 07:58:46
 
 
À
20/08/2010 05:02:07
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01474712
Message ID:
01477512
Vues:
89
' ... as safe as the for-next loop ...'

Not always. I learned the hard way, in PEM Editor, that even using FOXOBJECT was not always safe. Eventually I replaced all my loops with for-next loops, and my C5 errors disappeared.

>>Bernard nailed it. I've found that the issue is with the for-each construct. If you simply interate through using a standard For-next loop, referencing each item in the collection, you don't get any dangling references
>>
>>FOR x = 1 TO oCollection.Count
>> oItem = oCollection.Item(x)
>> * do whatever you need here
>>NEXT
>>
>>Give that a shot and see if the problem persists.
>
>BTW, you can still use the "for each ... in ..." if you include the "FOXOBJECT" clause in the end of the line. Originally, the for-each loop was a COM object and its interface was heavy for that, but at least it allowed for parsing collections in COM objects. The downside was that it was somewhat buggy when parsing Fox collections and arrays, which is why we got this clause in VFP9. With that clause, it uses native Fox objects, no COM interface, and is then as safe as the for-next loop.
Jim Nelson
Newbury Park, CA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform