//printing the number into the words.
//First one
static TempStr abc_numeralsToTxt_IN(real _num){
int numOfPaise = (decround(frac(_num), 2) * 100) mod 100;
real test = _num - frac(_num);
int numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, lakhs, crores;
int64 temp;
str 200 returntxt;
int tmp3;
str 200 returntxt1;
real modOperator(real a1, real a2)
{
int tmpi;
real tmp1, tmp2;
tmp1 = a1 / a2;
tmpi = real2int(tmp1);
tmp2 = tmpi;
return (tmp1 - tmp2)*a2;
}
real checkPower(real _test, int64 _power)
{
int64 numOfPower;
if (_test >= _power)
{
numOfPower = _test div _power;
if (numOfPower >= 100)
{
temp = numOfPower div 100;
returntxt = returntxt + ' ' + ones[temp] + ' ' + hundreds;
numOfPower = numOfPower mod 100;
}
if (numOfPower >= 20)
{
temp = numOfPower div 10;
returntxt = returntxt + ' ' + tenths[temp];
numOfPower = numOfPower mod 10;
}
if (numOfPower >= 1)
{
returntxt = returntxt + ' ' + ones[numOfPower];
numOfPower = numOfPower mod 10;
}
switch(_power)
{
case 10000000 :
{
if(returntxt == " One")
{
returntxt = returntxt + ' ' + "Crore";
_test = modOperator(_test, 10000000);
}
else
{
returntxt = returntxt + ' ' + crores;
_test = modOperator(_test, 10000000);
}
break;
}
case 100000 :
{
if(returntxt == " One")
{
returntxt = returntxt + ' ' + "Lakh";
_test = modOperator(_test, 100000);
}
else
{
returntxt = returntxt + ' ' + lakhs;
_test = modOperator(_test, 100000);
}
break;
}
case 1000 :
{
returntxt = returntxt + ' ' + thousands;
_test = modOperator(_test, 1000);
break;
}
case 100 :
{
returntxt = returntxt + ' ' + hundreds;
_test = modOperator(_test, 100);
break;
}
}
}
return _test;
}
#Define.text_1('One')
#Define.text_2('Two')
#Define.text_3('Three')
#Define.text_4('Four')
#Define.text_5('Five')
#Define.text_6('Six')
#Define.text_7('Seven')
#Define.text_8('Eight')
#Define.text_9('Nine')
#Define.text_10('Ten')
#Define.text_11('Eleven')
#Define.text_12('Twelve')
#Define.text_13('Thirteen')
#Define.text_14('Fourteen')
#Define.text_15('Fifteen')
#Define.text_16('Sixteen')
#Define.text_17('Seventeen')
#Define.text_18('Eighteen')
#Define.text_19('Nineteen')
#Define.text_20('Twenty')
#Define.text_30('Thirty')
#Define.text_40('Forty')
#Define.text_50('Fifty')
#Define.text_60('Sixty')
#Define.text_70('Seventy')
#Define.text_80('Eighty')
#Define.text_90('Ninety')
#Define.text_100('Hundred')
#Define.text_1000('Thousand')
#Define.text_100000('Lakhs')
#Define.text_10000000('Crores')
#Define.text_and('and')
ones[1] = #text_1;
ones[2] = #text_2;
ones[3] = #text_3;
ones[4] = #text_4;
ones[5] = #text_5;
ones[6] = #text_6;
ones[7] = #text_7;
ones[8] = #text_8;
ones[9] = #text_9;
ones[10] = #text_10;
ones[11] = #text_11;
ones[12] = #text_12;
ones[13] = #text_13;
ones[14] = #text_14;
ones[15] = #text_15;
ones[16] = #text_16;
ones[17] = #text_17;
ones[18] = #text_18;
ones[19] = #text_19;
tenths[1] = 'Not used';
tenths[2] = #text_20;
tenths[3] = #text_30;
tenths[4] = #text_40;
tenths[5] = #text_50;
tenths[6] = #text_60;
tenths[7] = #text_70;
tenths[8] = #text_80;
tenths[9] = #text_90;
hundreds = #text_100;
thousands = #text_1000;
lakhs = #text_100000;
crores = #text_10000000;
test = checkPower(test, 10000000);
test = checkPower(test, 100000);
test = checkPower(test, 1000);
test = checkPower(test, 100);
if (test >= 20)
{
numOfTenths = test div 10;
returntxt = returntxt + ' ' + tenths[numofTenths];
numOfTenths = numOfTenths mod 10;
test = test mod 10;
}
if (test >= 1)
{
numOfTenths = real2int(test);
returntxt = returntxt + ' ' + ones[numOfTenths];
}
if (numOfPaise)
{
if(numOfPaise >= 20)
{
tmp3 = numOfPaise div 10;
returntxt1 = returntxt1 + ' ' + tenths[tmp3];
numOfPaise = numOfPaise mod 10;
}
if(numOfPaise >= 1)
{
returntxt1 = returntxt1 + ' ' + ones[numOfPaise];
}
returntxt = ' ' + returntxt + ' ' + 'Rupees' + ' ' + #text_and + ' ' + returntxt1 + ' ' + 'paise';// + '***';
}
else
{
returntxt = ' ' + returntxt + ' ' + 'Rupees' + ' ';// + '***';
}
return returntxt;
}
//Second One
static TempStr abc_numericToTxt(Real _num)
{
int numOfPennies = frac(_num)*100 mod 100;
// int test = round(_num,0);
int test = any2int(round(_num,0));
int numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, Lakhs,millions, billions;
// real test1; comment by sanjeev
int test1; //added by sanjeev
int temp;
str 200 returntxt,returntxt1;
int checkPower(int _test, int _power)
{
int numOfPower;
if (_test >= _power)
{
numOfPower = _test DIV _power;
if (numOfPower >= 1000)
{
temp = numOfPower DIV 1000;
returntxt = returntxt + ' ' + ones[temp] + ' ' + hundreds;
numOfPower = numOfPower MOD 1000;
}
if (numOfPower >= 100)
{
temp = numOfPower DIV 100;
returntxt = returntxt + ' ' + ones[temp] + ' ' + Billions ; //hundreds;
numOfPower = numOfPower MOD 100;
}
if (numOfPower >= 20)
{
temp = numOfPower DIV 10;
returntxt = returntxt + ' ' + tenths[temp];
numOfPower = numOfPower MOD 10;
}
if (numOfPower >= 1)
{
returntxt = returntxt + ' ' + ones[numOfPower];
numOfPower = numOfPower MOD 10;
}
switch(_power)
{
case 1000000000 :
{
returntxt = returntxt + ' ' + Hundreds ;//billions;
_test = _test MOD 1000000000;
break;
}
case 10000000 :
{
returntxt = returntxt + ' ' + billions;
_test = _test MOD 10000000;
break;
}
case 100000 :
{
returntxt = returntxt + ' ' + lakhs;//millions;
_test = _test MOD 100000;
break;
}
case 1000 :
{
returntxt = returntxt + ' ' + thousands;
_test = _test MOD 1000;
break;
}
case 100 :
{
returntxt = returntxt + ' ' + hundreds;
_test = _test MOD 100;
break;
}
}
}
return _test;
}
ones[1] = "@SYS26620";
ones[2] = "@SYS26621";
ones[3] = "@SYS26622";
ones[4] = "@SYS26626";
ones[5] = "@SYS26627";
ones[6] = "@SYS26628";
ones[7] = "@SYS26629";
ones[8] = "@SYS26630";
ones[9] = "@SYS26631";
ones[10] = "@SYS26632";
ones[11] = "@SYS26633";
ones[12] = "@SYS26634";
ones[13] = "@SYS26635";
ones[14] = "@SYS26636";
ones[15] = "@SYS26637";
ones[16] = "@SYS26638";
ones[17] = "@SYS26639";
ones[18] = "@SYS26640";
ones[19] = "@SYS26641";
tenths[1] = 'Not used';
tenths[2] = "@SYS26643";
tenths[3] = "@SYS26644";
tenths[4] = "@SYS26645";
tenths[5] = "@SYS26646";
tenths[6] = "@SYS26647";
tenths[7] = "@SYS26648";
tenths[8] = "@SYS26649";
tenths[9] = "@SYS26650";
hundreds = "@SYS26651";
thousands = "@SYS26652";
lakhs = "Lakhs" ;
millions = "@SYS26653";
billions = "Crores" ;//"@SYS26654";
// numofpennies = roundup(numofpennies,2);
if( numofpennies >= 100)
{
NumofPennies = NumofPennies -100 ;
test = test +1 ;
}
test = checkPower(test, 1000000000);
test = checkPower(test, 10000000);
test = checkPower(test, 100000);
test = checkPower(test, 1000);
test = checkPower(test, 100);
if (test >= 20)
{
numOfTenths = test DIV 10;
returntxt = returntxt + ' ' + tenths[numofTenths];
numOfTenths = numOfTenths MOD 10;
test = test MOD 10;
}
if (test >= 1)
{
numOfTenths = test;
returntxt = returntxt + ' ' + ones[numOfTenths];
}
// numofpennies = roundup(numofpennies,2);
test1 = numofpennies ;
if (numOfPennies)
{
if (test1 >= 20)
{
numOfTenths = test1 DIV 10;
returntxt1 = returntxt1 + ' ' + tenths[numofTenths];
numOfTenths = numOfTenths MOD 10;
test1 = test1 MOD 10;
}
if (test1 >= 1)
{
numOfTenths = test1;
returntxt1 = returntxt1 + ' ' + ones[numOfTenths];
}
// returntxt = 'Rs. ' + returntxt + ' ' + "@SYS5534" + ' ' + returntxt1 + ' Paise Only';
// returntxt = 'Rs ' + returntxt + ' ' + "@SYS5534" + ' ' + num2str(numOfPennies,0,0,0,0) + ' Paise Only';
returntxt = returntxt + ' ' + "@SYS5534" + ' ' + returntxt1 + ' Paise Only';
}
else
{
// returntxt = 'Rs. ' + returntxt + ' ' + 'Only' ;// + "@SYS5534" + ' Only';
returntxt = returntxt + ' ' + 'Only' ;// + "@SYS5534" + ' Only';
}
return returntxt;
}
No comments:
Post a Comment