home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 21.6 Depreciation functions
- Author: Joe Booth
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- function sl(nCost,nScrap,nLife)
- LOCAL retarray[nLife],dp_amt:=(nCost-nScrap)/nLife
- afill(retarray,dp_amt)
- return retarray
-
-
- function syd(nCost,nScrap,nLife)
- LOCAL jj,arr_:={}
- for jj=1 to nLife
- Aadd(arr_,2*(nCost-nScrap)*(nLife+1-jj)/(nLife*(nLife+1)))
- next
- return arr_
-
-
- function db(nCost,nScrap,nLife)
- LOCAL accum:=0,jj,arr_:={}
- for jj=1 to nLife
- Aadd(arr_,(1-(nScrap/nCost)**(1/nLife))*(nCost-accum))
- accum += arr_[jj]
- next
- return arr_
-
-
- function ddb(nCost,nScrap,nLife)
- LOCAL accum:=0,jj,arr_:={},factor:=2/nLife
- LOCAL half:=int((nLife+1)/2)+1
- for jj=1 to nLife
- if jj < half
- Aadd(arr_,factor*(nCost-nScrap-accum))
- elseif jj=half
- Aadd(arr_,(nCost-nScrap-accum)/(nLife+1-half))
- else
- Aadd(arr_,arr_[jj-1])
- endif
- accum += arr_[jj]
- next
- return arr_
-
- // end of file CHP2106.PRG
-