public static str real2ArText(real _num)
{
real numOfPennies = decround(frac(_num), 2);
real test = _num - frac(_num);
str zero;
str comma;
str and;
str cent;
int numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, millions, billions, trillions;
int64 temp;
str 200 returntxt;
real modOperator(real a1, real a2)
{
int tmpi;
real tmp1, tmp2;
tmp1 = a1 / a2;
tmpi = real2int(tmp1);
tmp2 = tmpi;
return (tmp1 - tmp2)*a2;
}
str doubleDigit2ARTxt(real doubledigit,boolean _pennies = false)
{
str txt;
int firstDigit;
real tempdigit;
if(_pennies)
{
firstDigit = doubledigit * 10;
doubledigit = doubledigit * 100;
if(!firstDigit)
{
doubledigit = doubledigit mod 10;
//txt = zero + " " + ones[doubledigit];
txt = ones[doubledigit];
return txt;
}
}
tempdigit = doubledigit;
if (tempdigit >= 20)
{
tempdigit = tempdigit div 10;
txt = tenths[tempdigit];
doubledigit = doubledigit mod 10;
}
if (doubledigit >= 1)
{
txt = txt ? (ones[doubledigit] + and + txt) : ones[doubledigit];
}
return txt;
}
real checkPower(real _test,int64 _power)
{
int64 numOfPower;
if (_test >= _power)
{
numOfPower = _test div _power;
if (numOfPower >= 100)
{
temp = numOfPower div 100;
if(temp > 9)// The validation was previously on 2
{
returntxt = returntxt ? (returntxt + and + ones[temp] + ' ' + hundreds) :(returntxt + ' ' + ones[temp] + ' ' + hundreds);
}
else
{
switch(temp)
{
Case 1:
returntxt = returntxt ? (returntxt + and + hundreds) : (returntxt + ' ' + hundreds);
break;
Case 2:
// TO DO need to insert a label for two hundred in Arabic
returntxt = returntxt ? (returntxt + and + "مائتين") : returntxt + ' ' + "مائتين";
break;
Case 3:
// TO DO need to insert a label for three hundred in Arabic
returntxt = returntxt ? (returntxt + and + "ثلاثمائة") : returntxt + ' ' + 'ثلاثمائة';
break;
Case 4:
// TO DO need to insert a label for four hundred in Arabic
returntxt = returntxt ? (returntxt + and + "اربعمائة") : returntxt + ' ' + "اربعمائة";
break;
Case 5:
// TO DO need to insert a label for five hundred in Arabic
returntxt = returntxt ? (returntxt + and + "خمسمائة") : returntxt + ' ' + "خمسمائة";
break;
Case 6:
// TO DO need to insert a label for six hundred in Arabic
returntxt = returntxt ? (returntxt + and + "ستمائة") : returntxt + ' ' + "ستمائة";
break;
Case 7:
// TO DO need to insert a label for seven hundred in Arabic
returntxt = returntxt ? (returntxt + and + "سبعمائة") : returntxt + ' ' + "سبعمائة";
break;
Case 8:
// TO DO need to insert a label for eight hundred in Arabic
returntxt = returntxt ? (returntxt + and + "ثمانمائة") : returntxt + ' ' + "ثمانمائة";
break;
Case 9:
// TO DO need to insert a label for nine hundred in Arabic
returntxt = returntxt ? (returntxt + and + "تسعمائة") : returntxt + ' ' + "تسعمائة";
break;
}
}
numOfPower = numOfPower mod 100;
}
if(numOfPower > 2 && _power > 100)
{
returntxt = returntxt ? (returntxt + and + doubleDigit2ARTxt(real2int(numOfPower))) : (returntxt + ' ' + doubleDigit2ARTxt(real2int(numOfPower)));
}
else
{
if(returntxt && numOfPower)
{
returntxt = returntxt + and + ' ';
}
}
switch(_power)
{
case 1000000000000 :
{
if( numOfPower == 2)
{
// TO DO need to insert a label for two trillions in Arabic
returntxt = returntxt + "تريليونين ";
}
else
{
returntxt = numOfPower > 10 || numOfPower == 1 || numOfPower == 0 ? (returntxt + ' ' + trillions) : (returntxt + ' ' + "تريليونات");
}
_test = modOperator(_test, 1000000000000.00);
break;
}
case 1000000000 :
{
if( numOfPower == 2)
{
// TO DO need to insert a label for two billions in Arabic
returntxt = returntxt + "مليارين";
}
else
{
returntxt = numOfPower > 10 || numOfPower == 1 || numOfPower == 0 ? (returntxt + ' ' + billions) : (returntxt + ' ' + "مليارات");
}
_test = modOperator(_test, 1000000000);
break;
}
case 1000000 :
{
if( numOfPower == 2)
{
// TO DO need to insert a label for two Millions in Arabic
returntxt = returntxt + "مليونين";
}
else
{
returntxt = numOfPower > 10 || numOfPower == 1 || numOfPower == 0 ? (returntxt + ' ' + millions) : (returntxt + ' ' + "ملايين");
}
_test = modOperator(_test, 1000000);
break;
}
case 1000 :
{
if( numOfPower == 2)
{
// TO DO need to insert a label for two Thousands' in Arabic
returntxt = returntxt + "ألفين";
}
else
{
returntxt = numOfPower > 10 || numOfPower == 1 || numOfPower == 0 ? (returntxt + ' ' + thousands) : (returntxt + ' ' + "الاف");
}
_test = modOperator(_test, 1000);
break;
}
case 100 :
{
switch (numOfPower)
{
case 2:
returntxt = returntxt + "مائتين";
break;
case 3:
returntxt = returntxt +"ثلاثمائة";
break;
case 4:
returntxt = returntxt + "اربعمائة";
break;
case 5:
returntxt = returntxt + "خمسمائة";
break;
case 6:
returntxt = returntxt + "ستمائة";
break;
case 7:
returntxt = returntxt + "سبعمائة";
break;
case 8:
returntxt = returntxt + "ثمانمائة";
break;
case 9:
returntxt = returntxt + "تسعمائة";
break;
default:
returntxt = returntxt + ' ' + hundreds;
}
_test = modOperator(_test, 100);
break;
}
}
}
return _test;
}
infolog.language("AR");
// infolog.language("EN");
and = ' ' + "و" + ' ';//' ' + "@SYS5534" + ' ';
comma = "دينار";
//comma = "@SYS80142";
zero = "صفر";//"@SYS2068";
cent = "فلس";
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";
millions = "مليون";//"@SYS26653";
billions = "بليون";//"@SYS26654";
trillions = "تريليون";//"@SYS101697";
if(test == 0)
{
returntxt = zero;
}
else
{
test = checkPower(test, 1000000000000);
test = checkPower(test, 1000000000);
test = checkPower(test, 1000000);
test = checkPower(test, 1000);
test = checkPower(test, 100);
}
if(returntxt && test)
{
returntxt = returntxt + and + doubleDigit2ARTxt(real2int(test));
}
else
{
returntxt = returntxt + ' ' + doubleDigit2ARTxt(real2int(test));
}
if(numOfPennies)
{
//Removing the stars and addin the pound and cent wording to fullfil the Egyptian requierment
returntxt = ' فقط ' + returntxt + ' ' + comma + ' ' + and + doubleDigit2ARTxt(numOfPennies,true) + ' ' + cent + ' لاغير ';
//returntxt = '***' + returntxt + ' ' + comma + ' ' + doubleDigit2ARTxt(numOfPennies,true);
}
else
{
//Removing the stars and the zeros if no cents to fullfil the Egyptian requierment
returntxt = ' فقط ' + returntxt + ' ' + comma + ' لاغير ';
//returntxt = '***' + returntxt + ' ' + comma + ' ' + zero + ' ' + zero;
}
// infolog.language("EN");
return returntxt;
}
{
real numOfPennies = decround(frac(_num), 2);
real test = _num - frac(_num);
str zero;
str comma;
str and;
str cent;
int numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, millions, billions, trillions;
int64 temp;
str 200 returntxt;
real modOperator(real a1, real a2)
{
int tmpi;
real tmp1, tmp2;
tmp1 = a1 / a2;
tmpi = real2int(tmp1);
tmp2 = tmpi;
return (tmp1 - tmp2)*a2;
}
str doubleDigit2ARTxt(real doubledigit,boolean _pennies = false)
{
str txt;
int firstDigit;
real tempdigit;
if(_pennies)
{
firstDigit = doubledigit * 10;
doubledigit = doubledigit * 100;
if(!firstDigit)
{
doubledigit = doubledigit mod 10;
//txt = zero + " " + ones[doubledigit];
txt = ones[doubledigit];
return txt;
}
}
tempdigit = doubledigit;
if (tempdigit >= 20)
{
tempdigit = tempdigit div 10;
txt = tenths[tempdigit];
doubledigit = doubledigit mod 10;
}
if (doubledigit >= 1)
{
txt = txt ? (ones[doubledigit] + and + txt) : ones[doubledigit];
}
return txt;
}
real checkPower(real _test,int64 _power)
{
int64 numOfPower;
if (_test >= _power)
{
numOfPower = _test div _power;
if (numOfPower >= 100)
{
temp = numOfPower div 100;
if(temp > 9)// The validation was previously on 2
{
returntxt = returntxt ? (returntxt + and + ones[temp] + ' ' + hundreds) :(returntxt + ' ' + ones[temp] + ' ' + hundreds);
}
else
{
switch(temp)
{
Case 1:
returntxt = returntxt ? (returntxt + and + hundreds) : (returntxt + ' ' + hundreds);
break;
Case 2:
// TO DO need to insert a label for two hundred in Arabic
returntxt = returntxt ? (returntxt + and + "مائتين") : returntxt + ' ' + "مائتين";
break;
Case 3:
// TO DO need to insert a label for three hundred in Arabic
returntxt = returntxt ? (returntxt + and + "ثلاثمائة") : returntxt + ' ' + 'ثلاثمائة';
break;
Case 4:
// TO DO need to insert a label for four hundred in Arabic
returntxt = returntxt ? (returntxt + and + "اربعمائة") : returntxt + ' ' + "اربعمائة";
break;
Case 5:
// TO DO need to insert a label for five hundred in Arabic
returntxt = returntxt ? (returntxt + and + "خمسمائة") : returntxt + ' ' + "خمسمائة";
break;
Case 6:
// TO DO need to insert a label for six hundred in Arabic
returntxt = returntxt ? (returntxt + and + "ستمائة") : returntxt + ' ' + "ستمائة";
break;
Case 7:
// TO DO need to insert a label for seven hundred in Arabic
returntxt = returntxt ? (returntxt + and + "سبعمائة") : returntxt + ' ' + "سبعمائة";
break;
Case 8:
// TO DO need to insert a label for eight hundred in Arabic
returntxt = returntxt ? (returntxt + and + "ثمانمائة") : returntxt + ' ' + "ثمانمائة";
break;
Case 9:
// TO DO need to insert a label for nine hundred in Arabic
returntxt = returntxt ? (returntxt + and + "تسعمائة") : returntxt + ' ' + "تسعمائة";
break;
}
}
numOfPower = numOfPower mod 100;
}
if(numOfPower > 2 && _power > 100)
{
returntxt = returntxt ? (returntxt + and + doubleDigit2ARTxt(real2int(numOfPower))) : (returntxt + ' ' + doubleDigit2ARTxt(real2int(numOfPower)));
}
else
{
if(returntxt && numOfPower)
{
returntxt = returntxt + and + ' ';
}
}
switch(_power)
{
case 1000000000000 :
{
if( numOfPower == 2)
{
// TO DO need to insert a label for two trillions in Arabic
returntxt = returntxt + "تريليونين ";
}
else
{
returntxt = numOfPower > 10 || numOfPower == 1 || numOfPower == 0 ? (returntxt + ' ' + trillions) : (returntxt + ' ' + "تريليونات");
}
_test = modOperator(_test, 1000000000000.00);
break;
}
case 1000000000 :
{
if( numOfPower == 2)
{
// TO DO need to insert a label for two billions in Arabic
returntxt = returntxt + "مليارين";
}
else
{
returntxt = numOfPower > 10 || numOfPower == 1 || numOfPower == 0 ? (returntxt + ' ' + billions) : (returntxt + ' ' + "مليارات");
}
_test = modOperator(_test, 1000000000);
break;
}
case 1000000 :
{
if( numOfPower == 2)
{
// TO DO need to insert a label for two Millions in Arabic
returntxt = returntxt + "مليونين";
}
else
{
returntxt = numOfPower > 10 || numOfPower == 1 || numOfPower == 0 ? (returntxt + ' ' + millions) : (returntxt + ' ' + "ملايين");
}
_test = modOperator(_test, 1000000);
break;
}
case 1000 :
{
if( numOfPower == 2)
{
// TO DO need to insert a label for two Thousands' in Arabic
returntxt = returntxt + "ألفين";
}
else
{
returntxt = numOfPower > 10 || numOfPower == 1 || numOfPower == 0 ? (returntxt + ' ' + thousands) : (returntxt + ' ' + "الاف");
}
_test = modOperator(_test, 1000);
break;
}
case 100 :
{
switch (numOfPower)
{
case 2:
returntxt = returntxt + "مائتين";
break;
case 3:
returntxt = returntxt +"ثلاثمائة";
break;
case 4:
returntxt = returntxt + "اربعمائة";
break;
case 5:
returntxt = returntxt + "خمسمائة";
break;
case 6:
returntxt = returntxt + "ستمائة";
break;
case 7:
returntxt = returntxt + "سبعمائة";
break;
case 8:
returntxt = returntxt + "ثمانمائة";
break;
case 9:
returntxt = returntxt + "تسعمائة";
break;
default:
returntxt = returntxt + ' ' + hundreds;
}
_test = modOperator(_test, 100);
break;
}
}
}
return _test;
}
infolog.language("AR");
// infolog.language("EN");
and = ' ' + "و" + ' ';//' ' + "@SYS5534" + ' ';
comma = "دينار";
//comma = "@SYS80142";
zero = "صفر";//"@SYS2068";
cent = "فلس";
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";
millions = "مليون";//"@SYS26653";
billions = "بليون";//"@SYS26654";
trillions = "تريليون";//"@SYS101697";
if(test == 0)
{
returntxt = zero;
}
else
{
test = checkPower(test, 1000000000000);
test = checkPower(test, 1000000000);
test = checkPower(test, 1000000);
test = checkPower(test, 1000);
test = checkPower(test, 100);
}
if(returntxt && test)
{
returntxt = returntxt + and + doubleDigit2ARTxt(real2int(test));
}
else
{
returntxt = returntxt + ' ' + doubleDigit2ARTxt(real2int(test));
}
if(numOfPennies)
{
//Removing the stars and addin the pound and cent wording to fullfil the Egyptian requierment
returntxt = ' فقط ' + returntxt + ' ' + comma + ' ' + and + doubleDigit2ARTxt(numOfPennies,true) + ' ' + cent + ' لاغير ';
//returntxt = '***' + returntxt + ' ' + comma + ' ' + doubleDigit2ARTxt(numOfPennies,true);
}
else
{
//Removing the stars and the zeros if no cents to fullfil the Egyptian requierment
returntxt = ' فقط ' + returntxt + ' ' + comma + ' لاغير ';
//returntxt = '***' + returntxt + ' ' + comma + ' ' + zero + ' ' + zero;
}
// infolog.language("EN");
return returntxt;
}
No comments:
Post a Comment