I think you will find this white paper informative:
http://www.tomorrowssolutionsllc.com/Conference%20Sessions/Collections--Managing%20Information%20the%20Object-Oriented%20Way.pdf>Dear All
>
>I was working with a class that involved a Collection added at run time. I encountered a problem that I eventually managed to circumvent, but I would like to understand what was I doing wrong, if anything, with my original design.
>
>At first, I thought of a scope problem, but strangely I was able to access the Collection properties. What failed with me was that I couldn't (and cannot) access its items by any mean.
>
>I wrote a small program that reproduces my problem, with the help of the Debugger. If anyone is willing to give me a hand on this, I would ask to run the program and, when the debugger is launched and the program suspended, to insert the following watches (they are refered in the program so it will be easy to select each expression in the code and move it to the Watch field):
>
>This.Parameters.Count
>This.Parameters.GetKey(1)
>This.Parameters(m.lcKey)
>This.Parameters.Item(1)
>m.lnCount
>m.lcKey
>m.lnValueK
>m.lnValueN
>
>Afterwards, the program can be resumed a line at a time, and what I observed is that the variables got the expected values but all others watches could not be evaluated, with the exception of This.Parameters.Count that evaluated correctly to 3.
>
>My question is: what can explain this behavior of the items being inaccessible, athough the other properties of the Collection can be accessed - including the number of items in the Collection?
>
>The program:
>
>m.loObject = CREATEOBJECT("someClass")
>m.loObject.SetParameter("id", 1)
>m.loObject.SetParameter("model", "Model name")
>m.loObject.SetParameter("description", "Model description")
>m.loObject.someMethod()
>
>DEFINE CLASS someClass as Custom
>
> Parameters = .NULL.
>
> FUNCTION SetParameter
> LPARAMETERS tcId, teValue
>
> IF ISNULL(This.Parameters)
> This.Parameters = CREATEOBJECT("Collection")
> ENDIF
>
> This.Parameters.Add(m.teValue, m.tcId)
> ENDFUNC
>
> FUNCTION someMethod
>
> SET STEP ON
> m.lnCount = This.Parameters.Count
> m.lcKey = This.Parameters.GetKey(1)
> m.lnValueK = This.Parameters(m.lcKey)
> m.lnValueN = This.Parameters.Item(1)
> m.lcDummy = ""
>
> ENDFUNC
>
>ENDDEFINE
>