Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Object Reference
Message
From
27/12/2007 16:12:33
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
27/12/2007 16:02:22
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01277566
Message ID:
01277944
Views:
20
>>>You may want to update the FAQ, with two things. First, we now also have an option to have a collection of objects, which gives us two ways of accessing the members at random - by number (same as arrays) and by key (arrays can't do that without writing a loop or carefully designing aScan() check), and there's the same For Each option that works for arrays.
>>
>>Oh, my, I will have to study that, first. Could you provide some sample code? Or at least point me to the relevant help section.
>
>Just look at the collection class, instantiate one, try to see how it behaves. Note that .remove(-1) equals .clear() which I was looking for in vain.
>
>One example is how I once handled the parameters in a SPT handling class:
>
>
>procedure params_access()
>if isnull(this.params)
>	this.params=createobject("collection")
>endif
>return this.params
>
>*******************************
>procedure SetParam(cName, uValue)
>local oItem, oP
>oP=this.params
>if empty(oP.getkey(cName))
>	oItem=createobject("empty")
>	addproperty(oItem,"name", cName)
>	addproperty(oItem, "value", uValue)
>	oP.add(oItem, cName)
>else
>	oItem=oP.item(cName)
>	oItem.value=uValue
>endif
>
>*--- a part of .requery() method:
>for each oParam in this.params
>	private (oParam.name)
>	store oParam.value to (oParam.name)
>endfor
>
>
>So I had to just call oSpt.SetParam("vp_item", "443452") and oSpt.Requery() and it would handle it for me. I could have a group parameter set at some level and another inside a loop, and I wouldn't have to care about the other parameter - the collection would keep it for me.
>
>In some other cases, I had a collection of objects - for instance, any data handling class can have an object which is a collection of member objects of the same class - one per child table. I once had four such tables for one parent: a record in the concert table may have none, one or more of: performers, organizers, venues, artists, dates and subevents/sideshows. The class which handled the updates of a concert was actually handling, with minor differences (it selected records to update by foreign key, not timestamp), all of its child tables. The objects handling the children were in an member array because this was in VFP7 times - nowadays, I'd have a member collection of objects.

For the purposes of the FAQ, I want to have a collection/array of objects that are visible on the form (e.g., a group of related CheckBoxes, TextBoxes, etc.), and which can be accessed through an index or key.

Perhaps Collections work, but I'll have to do some testing first, and produce some sample code specifically for this need.

Thanks for the information.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform