Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Don't know how to process collection returned by com object
Message
From
09/07/2004 15:14:57
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Don't know how to process collection returned by com object
Miscellaneous
Thread ID:
00922659
Message ID:
00922659
Views:
67
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
Next
Reply
Map
View

Click here to load this message in the networking platform