Instead of returning just an array of invoice numbers, it returns an array of invoice objects. This allows us to use any of the data and/or methods of the objects. Very useful. You could, for example, use the invoice number, date and total in a report.
Note that it is fully encapsulated--it opens it's own copy of the invoice file, uses it, then closes it.
- Code: Select all Expand view
- Method GetInvoices() Class TCustomer
Local oInvoices := TInvoices():New()
Local aInvoices := {}
oInvoices:setOrder( "CUSTNO" )
oInvoices:setScope( ::CustNo, ::CustNo )
oInvoices:gotop()
do while .not. oInvoices:eof
aadd( aInvoices, TInvoice():New( oInvoices:InvNo ) )
oInvoices:skip()
enddo
oInvoices:end()
Return aInvoices