Wednesday 29 August 2018

Convert Numbers into Words

WordNum is the function which returns the English text equivalent of a given number.

For Example:
Expression
Returns
WordNum(123.45)One Hundred and Twenty-three Dollars
WordNum(123.45, 1)One Hundred and Twenty-three Dollars
WordNum(1154.67, 2)One Thousand One Hundred Fifty-four Dollars And Sixty-seven Cents
WordNum(43, 2)Forty-three Dollars And Zero Cents
WordNum(Amount[0], 2)
This example uses the first occurrence of Amount as the conversion number.
 However, there is a limitation in this fuction. It only converts the two decimal values and if you want to English conversion for more than 2 decimals then you need to use the JavaScript to modify the function.
This is required in case of currency conversion for example Omani Rial, where 3 decimal values are acceptable.

Note: This function runs in Formcalc language so all coding needs to be done in FormCalc only.


Number To Word
Snippet:

if ($.rawValue == "OMR") then
var last = right(TextField1,3)
var part1 = Concat(WordNum(TextField1), " rials And ")
var part2 = Concat(WordNum(last) , " baisa")
TextField2.rawValue = Concat(part1 , part2)
endif


Source: https://www.dropbox.com/s/dvn68wm3oybs43l/sampleNumToWord.pdf?dl=0

No comments:

Post a Comment