home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP21.EXE / CHP2106.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  1.1 KB  |  50 lines

  1. /*
  2.    Listing 21.6  Depreciation functions
  3.    Author: Joe Booth
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. function sl(nCost,nScrap,nLife)
  12. LOCAL retarray[nLife],dp_amt:=(nCost-nScrap)/nLife
  13. afill(retarray,dp_amt)
  14. return retarray
  15.  
  16.  
  17. function syd(nCost,nScrap,nLife)
  18. LOCAL jj,arr_:={}
  19. for jj=1 to nLife
  20.    Aadd(arr_,2*(nCost-nScrap)*(nLife+1-jj)/(nLife*(nLife+1)))
  21. next
  22. return arr_
  23.  
  24.  
  25. function db(nCost,nScrap,nLife)
  26. LOCAL accum:=0,jj,arr_:={}
  27. for jj=1 to nLife
  28.    Aadd(arr_,(1-(nScrap/nCost)**(1/nLife))*(nCost-accum))
  29.    accum += arr_[jj]
  30. next
  31. return arr_
  32.  
  33.  
  34. function ddb(nCost,nScrap,nLife)
  35. LOCAL accum:=0,jj,arr_:={},factor:=2/nLife
  36. LOCAL half:=int((nLife+1)/2)+1
  37. for jj=1 to nLife
  38.    if jj < half
  39.       Aadd(arr_,factor*(nCost-nScrap-accum))
  40.    elseif jj=half
  41.       Aadd(arr_,(nCost-nScrap-accum)/(nLife+1-half))
  42.    else
  43.       Aadd(arr_,arr_[jj-1])
  44.    endif
  45.    accum += arr_[jj]
  46. next
  47. return arr_
  48.  
  49. // end of file CHP2106.PRG
  50.