 How to Convert Real numbers into text

Hi All,

Can any one tell how can i write the real no’s into txt.

For eg:- 768.23 as Seven hundred sixty eight and twenty three paise.

when i use the numeralstotxt ,it is showing as 23/100 paise .I want to show the paise too in correct format .What I should do ,can anybody suggest?

Thank You

Abhishek Bhati

this will help u

http://dynamicsuser.net/forums/t/32825.aspx

Hi kunal,

Thanks kunal for the reply .I already had gone through that post .By doing that I am getting the output after decimal as 23/100 but I want the output as twenty three in words.

Is there any way to covert the vailue after decimals to the words.

Thanks

Abhishek can u show me ur code plz

hi…

try this code…

1. To write one new method in global class in AOT.

i.e)

static TempStr realToTxt(real _num)
{
int numOfPennies = (decround(frac(_num), 2) * 100) mod 100;
real test = _num - frac(_num);

int numOfTenths;
str 20 ones, tenths, hundreds, thousands, millions, billions, trillions;

int64 temp;
str 200 returntxt;

//number to text —
real fracnum=frac(_num);

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 1000000000000 :
{
returntxt = returntxt + ’ ’ + trillions;
_test = modOperator(_test, 1000000000000.00);
break;
}
case 1000000000 :
{
returntxt = returntxt + ’ ’ + billions;
_test = modOperator(_test, 1000000000);
break;
}
case 1000000 :
{
returntxt = returntxt + ’ ’ + millions;
_test = modOperator(_test, 1000000);
break;
}
case 1000 :
{
returntxt = returntxt + ’ ’ + thousands;
_test = modOperator(_test, 1000);
break;
}
case 100 :
{
returntxt = returntxt + ’ ’ + hundreds;
_test = modOperator(_test, 100);
break;
}
}
}
return _test;
}

ones = “@SYS26620”;
ones = “@SYS26621”;
ones = “@SYS26622”;
ones = “@SYS26626”;
ones = “@SYS26627”;
ones = “@SYS26628”;
ones = “@SYS26629”;
ones = “@SYS26630”;
ones = “@SYS26631”;
ones = “@SYS26632”;
ones = “@SYS26633”;
ones = “@SYS26634”;
ones = “@SYS26635”;
ones = “@SYS26636”;
ones = “@SYS26637”;
ones = “@SYS26638”;
ones = “@SYS26639”;
ones = “@SYS26640”;
ones = “@SYS26641”;

tenths = ‘Not used’;
tenths = “@SYS26643”;
tenths = “@SYS26644”;
tenths = “@SYS26645”;
tenths = “@SYS26646”;
tenths = “@SYS26647”;
tenths = “@SYS26648”;
tenths = “@SYS26649”;
tenths = “@SYS26650”;

hundreds = “@SYS26651”;
thousands = “@SYS26652”;
millions = “@SYS26653”;
billions = “@SYS26654”;
trillions = “@SYS101697”;

test = checkPower(test, 1000000000000);
test = checkPower(test, 1000000000);
test = checkPower(test, 1000000);
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 (numOfPennies)
{
returntxt = returntxt + ’ ’ + “@SYS5534” + ’ cents ';
if(numOfPennies>=20)
{
numOfTenths=numOfPennies div 10;
numOfPennies = numOfPennies mod 10;
returntxt = returntxt + ’ ’ + tenths[numofTenths];
}
if (numOfPennies >= 1)
{
numOfTenths = real2int(numOfPennies);

returntxt = returntxt + ’ ’ + ones[numOfTenths];

}
returntxt = returntxt;
}
else
{
returntxt = returntxt ;
}

return returntxt;
}

1. use this method …suppose to write job using this method…

static void TestNumeralsToTxt(Args _args)
{
AmountCur AmountCur;
str val;

;

AmountCur = 715.99;
val = realToTxt(AmountCur);
val = substr(val,5, strlen(val)-4);
print val;
pause;

}

1. To get the correct output.

Thank You.

Hi ,

It is same as given in that post .Still I am describing it below.Please edit it and solve my issue if you know any solution behind it.

static void TestNumeralsToTxt(Args _args)

{

AmountCur AmountCur;

str val;

;

AmountCur = 768.23;

val = numeralsToTxt_EN(AmountCur);

val = substr(val,5, strlen(val)-4);

print val;

pause;

}

Hi Laxmi,

Thanks Very much .You really hv solved my problem.

Thanx once again.

static void Job42(Args _args)
{
AmountCur AmountCur;

str val;

;

AmountCur = 768.23;

val = Global::numeralsToTxt_IN(AmountCur);

val = substr(val,5, strlen(val)-4);

info(strfmt(val));

// pause;

}

thanks for elaborating it and i am very grateful for the post. thanks again. karla

low interest car loans