*-- With VFP8's native collection class it would look like so: loCollection = CREATEOBJECT("Collection") loCollRefToBeStoredInCollection = CREATEOBJECT("Collection") loCollection.Add(loCollRefToBeStoredInCollection) *-- Here we are adding an item to the collection object of which *-- a reference is stored in the first item of loCollection loCollection.Item(1).Add("Some value")The following code demonstrates for what I really use the assign method. It's simply a wrapper for the internal array. I ask for an array property (Items) value and simply return an array item from the internal array. Since the returned array element is an object reference, I can directly call methods in the returned object just like I would be able to call an object's methods when it is stored in a public array property without an assign method. I hope I was able to describe this properly, so you can follow the thoughts behind the code.
*-------------------------------------------------------------- *-- *-- Visual FoxPro 08.00.0000.2521 for Windows *-- *-- Works fine in Visual FoxPro 07.00.0000.9465 for Windows *-- *-- Demonstrates possible access method bug when directly *-- calling a method in the returned object like so: *-- *-- THIS.uProp(1).Add("1") *-- *-- The access method gets .F. instead of 1 as it's *-- parameter value. For workarounds see below. *-- *-- Submitted by armin.neudert@ansta.de *-- 02-19-2003 08:50 pm *-- Version 2 *-------------------------------------------------------------- LOCAL loCollection, loCollRefToBeStoredInCollection loCollection = CREATEOBJECT("myCollection") loCollRefToBeStoredInCollection = CREATEOBJECT("myCollection") loCollection.Add(loCollRefToBeStoredInCollection) *-- Here we are adding an item to the collection object of which *-- a reference is stored in the first item of loCollection *-- Error in VFP8! loCollection.Item(1).Add("Some value") *-- No error! LOCAL loTemp loTemp = loCollection.Item(1) loTemp.Add("Some value") RETURN DEFINE CLASS myCollection AS Session *-- This array is only there so we can have *-- an access method we can use to wrap *-- access to the internal array DIMENSION Item[1] *-- This array is the internal one that *-- holds our items. No direct access *-- from the outside allowed (encapsulation!) PROTECTED aItems[1] PROCEDURE Add LPARAMETERS tluItem IF THIS.aItems[1] <> .F. DIMENSION THIS.aItems[THIS.ALEN(aItems)+1] ENDIF THIS.aItems[ALEN(THIS.aItems)] = tluItem ENDPROC PROCEDURE Item_Access LPARAMETERS tlnIndex MESSAGEBOX( "Index passed to access method: " + TRANSFORM(tlnIndex) ) RETURN THIS.aItems[tlnIndex] ENDPROC ENDDEFINE>Are you using a documented feature that I am not aware or is this code taking advantage of an anomaly in VFP?