*function rupeewrd

parameter pnamount

*	First Of all build string for Rupees
*	It is assumed that Paisa for supplied amount would be < 100

private rupeewrd 

rupeewrd = ''
if pnamount = 0.00
	retu('Zero')
endif	
if int(pnamount) <> 0
	rupeewrd = below_abaj(int(pnamount)) + ' ' 
endif
if pnamount - int(pnamount) <> 0
	rupeewrd = rupeewrd + 'and paise ' + below_100((pnamount - int(pnamount))*100) 
endif
retu(rupeewrd + ' only')

function formula_100

parameter pnamount

do case
	case pnamount = 2
		retu('Twen')
	case pnamount = 3
		retu('Thir')
	case pnamount = 4
		retu('Four')
	case pnamount = 5
		retu('Fif')
	case pnamount = 8
		retu('Eigh')
	othe
		retu(below_10(pnamount))
endc


function below_100

parameter pnamount

do case
	case pnamount > 19
		retu(allt(formula_100(int(pnamount/10)) + 'ty ' + below_10(pnamount - int(pnamount/10)*10)))

	case pnamount > 12
		retu(formula_100(pnamount - 10) + 'teen')
		
	case pnamount = 12
		retu('Twelve')

	case pnamount = 11
		retu('Eleven')

	case pnamount = 10
		retu('Ten')
		
	case pnamount < 10
		retu(below_10(pnamount))
endc

function below_10

parameter pnamount

do case
	case pnamount = 0
		retu('')
	case pnamount = 1
		retu('One')
	case pnamount = 2
		retu('Two')
	case pnamount = 3
		retu('Three')
	case pnamount = 4
		retu('Four')
	case pnamount = 5
		retu('Five')
	case pnamount = 6
		retu('Six')
	case pnamount = 7
		retu('Seven')
	case pnamount = 8
		retu('Eight')
	case pnamount = 9
		retu('Nine')
*	case pnamount = 0
*		retu('Zero')	
	othe
		retu('Error')	
endcase		

function below_thousand

para pnamount

retu(iif(pnamount >= 100,below_10(int(pnamount/100)) + ' Hundred ','') + below_100(pnamount - int(pnamount/100)*100))

function below_lakh

para pnamount

retu(iif(pnamount >= 1000,below_100(int(pnamount/1000)) + ' Thousand ','') + below_thousand(pnamount - int(pnamount/1000)*1000))

function below_carore

para pnamount

retu(iif(pnamount >= 100000,below_100(int(pnamount/100000)) + ' Lakh ','') + below_lakh(pnamount - int(pnamount/100000)*100000))

function below_abaj

para pnamount

retu(iif(pnamount >= 10000000,below_100(int(pnamount/10000000)) + ' Carore ','') + below_carore(pnamount - int(pnamount/10000000)*10000000))

