Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Properly cycle through collection class
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00907793
Message ID:
00907808
Views:
6
This message has been marked as the solution to the initial question of the thread.
Troy,

It's known issues with collections. A FOR EACH loop uses COM interface to access items in a collection. It's recomended to use regular FOR ... ENDFOR loop instead. For more details see FOR EACH Enumerations of VFP Collections Do Not Provide True Object References Bug #9

>Hello,
>I am trying to work with some objects that have been added to a collection class from a table using the scatter command. However every time I try to use the for each command nothing really works but, if I go through with the item method it works fine.
>
>This does not work.
>
>oHolder = createobject("Collection")
>use sometable
>scan all
>  scatter memo name oTemp
>  oHolder.Add(oTemp)
>endscan
>for each oEtc in oHolder
>  ? oEtc.name && this is a field in table
>endfor
>
>
>This will work.
>
>oHolder = createobject("Collection")
>use sometable
>scan all
>  scatter memo name oTemp
>  oHolder.Add(oTemp)
>endscan
>for i = 1 to oHolder.count
>  ? oHolder.item(i).name && this is a field in table
>endfor
>
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform