;Example of bdbfs plugin file.
;Returns the future value of an investment.
;FoxPro's name is Fv().
;Two formats:
;1)constant periodic payment, interest rate, number of payments
;2)year payment, interest rate, number of years, number of per year,
;  number of payments per year
;If some parameters are omitted calls the dialogue.

PARAMETERS nConst,nPercent,nNumber,nPay,nInv
LOCAL nRes, color, _aGets, _aVars, lEdit:=.F.

cCodePage:='cp866'
IF VALTYPE(nInv)<>'N'
	nInv:=1
	lEdit:=.T.
ENDIF
IF VALTYPE(nPay)<>'N'
	nPay:=1
	lEdit:=.T.
ENDIF
IF VALTYPE(nNumber)<>'N'
	nNumber:=1
	lEdit:=.T.
ENDIF
IF VALTYPE(nPercent)<>'N'
	nPercent:=1
ENDIF
IF VALTYPE(nConst)<>'N'
	nConst:=0
ENDIF

IF lEdit
*Something is absent
	color:=SetColor(m->_im)
	ScrSave()
	Panel(9,10,16,69,{'Future value investment'}, {_im, _im, _im})
	DevPos(16, 14)
	DevOut('F10 - Done', _HdColor)
	_aVars:={nConst,nPercent,nNumber}
	_aGets:={ {12,14,'Constant payment','999999.99'},;
		  {12,44,'Interest rate','999.99'},;
		  {14,14,'Number of payments','999'}}
	IF !ReadCycle(_aGets,_aVars,15,MaxCol()-20)
		ScrRest()
		RETURN 0
		#BREAK
	ENDIF
	ScrRest()
	nConst:=_aVars[1]
	nPercent:=_aVars[2]
	nNumber:=_aVars[3]
ENDIF
nRes:=1+nPercent*0.01/nPay
RETURN nConst*(nRes^(nNumber*nPay) - 1)/((nRes^(nPay/nInv)-1)*nInv)
