Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with collections
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01356180
Message ID:
01356549
Views:
23
Evan --

Thanks for your reply.

First, it is true that in my case This.Fields contains a collection of objects, based on the empty class, with identical property names.

Second, my problem in loProperties.Fields was in the way I referenced it (apparently). It seems like loProperties.Fields(1) did not work property, whereas loProperties.Fields.Item(1) does work propertly

My last statement about loProperties.Fields(1) was because of the properties it exposed in the debugger -- yup, it looked like a collection


>James,
>
>I use collections heavily in almost everything I write with VFP. Yet, I'm a bit confused as to exactly what the issues are in this situation.
>
>First, if This.Fields is a collection of *objects* with identical property names and counts, are those contained objects based on the Empty class? If not (say, they're based on the Custom or Relation class, for instance), you may be getting method and/or event names you don't want along with your property names. That's not a good thing, and could be messing up your result object.
>
>Second, what *exactly* are the (undesired) differences between the source object in This.Fields and the resulting object in loProperties.Fields? A bit more information would be helpful here...
>
>Third, what leads you to believe that loProperties.Fields(1) "actually looks like a collection itself" ? Does that object have a base class of Collection when you look at it in the Debugger?
>
>
>>I'm having problems working with Collections (not surprisingly, since this is my very first time creating a collection).
>>
>>I have a form with a collection named .Fields .... This.Fields (I've inherited this from somebody else). Each item in This.Fields is an object with the same simple list of properties.
>>
>>I want to copy the entire collection into an object I've created called loProperties. Now, I don't want to copy an object reference, since my goal is to later compare the values in This.Fields with loProperties.Fields. to see which have changed.
>>
>>My code to do this follows. When done, however, loProperties.Fields(1) does not have the same list of properties as This.Fields(1) --- it actually looks like a collection itself.
>>
>>Can anybody identify what I'm doing wrong here? (Note: loFields looks like the collection I would expect ... but loProperties.Fields doesn't)
>>
>>
	loFields = Createobject("Collection")
>>	For lnJ = 1 To This.Fields.Count
>>		m.loData = Createobject("Empty")
>>		Amembers(laFieldMembers, This.Fields(lnJ))
>>		For Each lcFieldMem In laFieldMembers)
>>			AddProperty(m.loData, lcFieldMem, Evaluate("This.Fields(lnJ)." + lcFieldMem))
>>		Endfor
>>
>>		loFields.Add(m.loData)
>>	Next lnJ
>>	AddProperty (loProperties, 'Fields', loFields)
>>
Jim Nelson
Newbury Park, CA
Previous
Reply
Map
View

Click here to load this message in the networking platform