>I am writing a vfp7 app. I am using a component called atfincalc. I don't have a lot of experience with collections. The developer has sample vb code that I am trying to get to work in VFP. One of the methods returns a collection:
>
>Using a for each loop seems to work right,I can access the flow object. But it doesn't work to reference the flow object via the flows element number.
>
>Are these problems due to: a) syntax errors on my part b)vfp doesn't support collections in the same way vb does
>
>I haven't tried this in vfp8 - have heard it has better support for collections - but have heard there are problems with it.
>
>
>oLoan = CreateObject("AtFinCalc.Loan")
>oFlowItem=CreateObject("AtfinCalc.CashFlow")
>oFlows=CreateObject("AtfinCalc.CashFlows")
>
>orig = 100000
>oloan.Amount = orig
>oloan.Periods = 15 * 12
>oloan.Rate = .0725 / 12
>payment = oloan.CalcPayment()
>?payment
>flows=oloan.CalcCashFlows()
>
>*-- works in vfp - but debugger doesn't recognize flows and flow
>*-- in the same way that it does oFlows and oFlowItem
>*-- amembers doesn't work on this object
>for each flow in flows
> *' Do processing
> interest = flow.Interest &&' Interest Paid
> ?interest
> payment = flow.Payment &&' Payment Amount
> principle = flow.principle
> ?payment
>next flow
>
>
>*-- doesn't work in vfp - took this code from their vb example and revised
>for i = 0 to flows.Count - 1
>
> balance = flows(i).Balance && get error flows is not an array
> ocurrent=flows(i) && error 'flows.prg does not exist
> ?ocurrent.balance
> next i
David,
Have you registered the objects with the Intellisense Manager? And do they supply a type library?
In earlier versions of VFP this was a pretty common occurrence. Properties weren't "seen" unless they had first been referenced.
George
Ubi caritas et amor, deus ibi est