Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

convert currency values in words

Avatar

Level 2

i wants to convert indian currency in words i.e 199 (rupees one hundred ninety nine only) is there anybody who can tell me how to do the same

1 Accepted Solution

Avatar

Correct answer by
Employee

Slight modifications: Spellings of dollars are incorrect which would cause incorrect replacement of the string. Also modified the code slightly. Please try it out and debug yourself.

form1.#subform[0].AMT_WORDS::exit - (FormCalc, client)

//RTGS_AMT::exit-(form calc,client)

var Y;

var Z;

Z = RTGS_AMT.rawValue;

AMT_WORDS.rawValue= WordNum(Z,2);

Y = AMT_WORDS.rawValue;

Y = Replace(Y,"Dollars","Rupees"); // changed spellings here.

Y = Replace(Y,"Cents","Paise");

AMT_WORDS.rawValue = Y;

// AMT_WORDS = WordNum(RTGS_AMT,Z,2); // This is not required.

View solution in original post

20 Replies

Avatar

Level 2

sir,

i have tried the same but it can only convert the values in dollers i need the same to convert the values in indian currency how do it come possible for me

uma shankar

Avatar

Employee

This function is only supported for English (US) localei .e. for Dollar.

WordNum(n1 [, n2 [, k ]]) where k is the locale.

For Indian currency, you'll have to do it a bit differently.

1) Get the number in words before the decimal point using the WordNum function.

2) Get the number in words after the decimal point using the WordNum function.

Create the appropriate string by appending string "rupees" and "paise" at required places in the text field where you would be displaying the value. this is what I could think of at this point of time. Try it out. This should work.

Avatar

Level 2

how we can create the string in word num function because all the formula is inbuilt

uma shankar

Avatar

Employee

Parse the number separated through the decimal field and use WordNum function to generate strings for the resultant numbers. Eg:

Let's say you have two fields in the form. 1 numeric field which holds the value you wish to convert into words and 1 textfield where you wish to display the value. Use a script like:

sf1.TextField1.rawValue = WordNum(sf1.NumericField1)

This would give you the value of number (before the decimal) in words. Of course, you need not assign this value to a field as I did. this was just an illustration and you can use a variable in script to store values.Similarly, you can do the same for number after the decimal.

Avatar

Level 2

Sir,

Could you please write a simple illustrative code in reply so i can easily understand the same, it would be the greatest pleasure for me to get assisted by you

uma shankar

Avatar

Employee

Here's how you can do this.

"Get the value in dollars and cents using WordNum function and replace "dollar" and "cents" with "rupees" and "paise" respectively.

I have a numeric field NumericField1, TextField1 displays its value in dollars/cents and TextField2 displays rupees/paise. Try this script written on exit event on numeric field once a value is entered in numeric field. You can customize the script based on your use case.

// form1.sf1.NumericField1::exit - (FormCalc, client)

var y;

var z;

z = sf1.NumericField1.rawValue;

sf1.TextField1.rawValue= WordNum(z,2);

y = sf1.TextField1.rawValue;

y = Replace(y,"Dollars","Rupees");

y = Replace(y,"Cents","paise");

sf1.TextField2.rawValue = y;

Avatar

Level 2

Dear sir,

i have created database of adobe livecycle form it working properly on my home pc but as well as i have coppied the same on my office pc it dosent work properly rather ms access is installed on both systems but it is not creating the database at the office pc, how do it come possible for me to proper functionality at office system, is it require the data file as well as the form on the office pc

uma shankar

Avatar

Employee

Good to know that your original issue of currency conversion is solved.

Please check your MS access installation. It's working on one of your systems, hence it must be some issue in configuration/installation.

Avatar

Level 2

sir,

i have tried the currency formula which you have mentioned earlier in your reply i found that the variable which we have declared in the script editor the programme gives an error at line no. 2 column no. 6 which is variable y i am attaching the error file anong with the code which i have putted into it.

error.png

This is the code which i have putted into script writer

form1.#subform[0].AMT_WORDS::exit - (FormCalc, client)

//RTGS_AMT::exit-(form calc,client)

var Y,Z;

Z = RTGS_AMT.rawValue;

AMT_WORDS.rawValue= WordNum(Z,2);

Y = AMT_WORDS.rawValue;

Y = Replace(Y,"Dollers","Rupees");

Y = Replace(Y,"Cents","Paise");

AMT_WORDS.rawValue = Y;

AMT_WORDS = WordNum(RTGS_AMT,Z,2);

Avatar

Employee

Instead of using the statement:

var Y,Z;

Use

var Y;

var Z;

i.e. you need to split up the var declarations. Thisi s not javascript but formcalc and hence, this nuance.

This should do it!

-Saket.

Avatar

Level 2

rest is perfect or need some altration

Avatar

Correct answer by
Employee

Slight modifications: Spellings of dollars are incorrect which would cause incorrect replacement of the string. Also modified the code slightly. Please try it out and debug yourself.

form1.#subform[0].AMT_WORDS::exit - (FormCalc, client)

//RTGS_AMT::exit-(form calc,client)

var Y;

var Z;

Z = RTGS_AMT.rawValue;

AMT_WORDS.rawValue= WordNum(Z,2);

Y = AMT_WORDS.rawValue;

Y = Replace(Y,"Dollars","Rupees"); // changed spellings here.

Y = Replace(Y,"Cents","Paise");

AMT_WORDS.rawValue = Y;

// AMT_WORDS = WordNum(RTGS_AMT,Z,2); // This is not required.

Avatar

Level 1

worked successfully.
After trying various methods, found your post.
Thanks a lot

Avatar

Level 2

Sir,

One more thing i would like to know that how i can set the digit terms in form calculation (i.e. if i have put a figure 100,000 the output come as one hundred thousand instead of one lac ) i have set the digit for lac but it only convert the value of 100000 when i went further it converts the value as usual like two hundred thousand,three hundred thousand. What would be the solution for that. I also have two numeric fields will it work for both fields if yes then what changes should be made in the script so that i can get the results.

regards

uma shankar

Avatar

Employee

Y = Replace(Y,"hundred thousand", "lac");

Avatar

Level 2

sir,

it only work if we converts the value from 100000 to 120000 but as well as we move further like 120001 it gets fail & converts the value in usual manner i.e. one hundred twenty thousand one only

regards

uma shankar

Avatar

Level 1

This works great how , could the same be working for 3 decimals , it tried to convert to string and read the value with right function , but it fails as soon as there is number ends with zeros .Please help .

Grandtotal.format.picture.value = "z,zzz,zz9.999"

var x = wordnum(numtoword)

var y  = Right(Grandtotal, 3)

y = wordnum(y)

this.rawValue = Concat(x," Currency And ",Subcurrency," Fils")

Avatar

Level 1

Hi

I want to convert UAE currency in words i.e 10,199.55 (Ten Thousand One Hundred Ninety-nine & Fils Fifty-five Only) is there anybody who can tell me how to do the same.

 

Regards

 

Polson