Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dangling reference?
Message
From
20/08/2010 07:58:46
 
 
To
20/08/2010 05:02:07
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01474712
Message ID:
01477512
Views:
88
' ... 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
Previous
Reply
Map
View

Click here to load this message in the networking platform