0

# Change

How can change number to text. For example amount in invoice is 5000usd . I will see text too in down invoice. Five thousand dollars

68replies Oldest first
• Oldest first
• Popular
• Sean
• Sean
• 4 yrs ago
• Reported - view

Like
• New Sun
• New_Sun
• 4 yrs ago
• Reported - view

It is seem correct and worked. I think in point have problem

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

For some reason the user defined function is truncating the "0". If the formula is used by itself, not as a function, it works. I'll try to figure it out later tonight. Gotta go to work now.

Like
• New Sun
• New_Sun
• 4 yrs ago
• Reported - view

thank you

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

Do you want it as 50/100 or Fifty Cents?

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

I just did both and I changed my field name to Net so you don't have to change anything.

This is the code for Cents Fraction:

`let empty := "";let x := [empty, "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "];let y := [empty, empty, "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "];"/*                       ";" * User defined functions";" */                      ";function mod(dividend : number,divisor : number) dodividend - divisor * floor(dividend / divisor)end;function numberToWord(num : number,suffix : text) doif floor(num) != 0 thenif num > 19 thenitem(y, floor(num / 10)) + item(x, mod(num, 10)) + suffixelseitem(x, num) + suffixendelseemptyendend;"/*             ";" * Main program";" */            ";"// Number to be converted to words";let numAmount := Net;"// Test for number of digits";if length(format(floor(numAmount), "0")) < 11 then"// String to store word representation of given number";let NtW := "";"// This handles Cents";if contains(text(numAmount), ".") thenlet dpIndex := index(text(numAmount), ".");NtW := "and " + substr(text(numAmount), dpIndex + 1, 2) + "/100 usd"end;"// This handles digits at Ones and Tens place";NtW := numberToWord(mod(numAmount, 100), "") + NtW;"// This handles digit at Hundreds place";NtW := numberToWord(mod(numAmount / 100, 10), "Hundred ") + NtW;"// This handles digits at One Thousands and Ten Thousands place";NtW := numberToWord(mod(numAmount / 1000, 100), "Thousand ") + NtW;"// This handles digit at Hundred Thousands place";NtW := numberToWord(mod(numAmount / 100000, 10), "Hundred ") + NtW;"// This handles digits at One Millions and Ten Millions place";NtW := numberToWord(mod(numAmount / 1000000, 100), "Million ") + NtW;"// This handles digit at Hundred Millions place";NtW := numberToWord(mod(numAmount / 100000000, 10), "Hundred ") + NtW;"// This handles digit at One Billions place";NtW := numberToWord(mod(numAmount / 1000000000, 10), "Billion ") + NtW;NtWelse"Number is too large"end`

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

This is the code for Cents Words:

`let empty := "";let x := [empty, "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "];let y := [empty, empty, "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "];"/*                       ";" * User defined functions";" */                      ";function mod(dividend : number,divisor : number) dodividend - divisor * floor(dividend / divisor)end;function numberToWord(num : number,suffix : text) doif floor(num) != 0 thenif num > 19 thenitem(y, floor(num / 10)) + item(x, mod(num, 10)) + suffixelseitem(x, num) + suffixendelseemptyendend;"/*             ";" * Main program";" */            ";"// Number to be converted to words";let numAmount := Net;"// Test for number of digits";if length(format(floor(numAmount), "0")) < 11 then"// String to store word representation of given number";let NtW := "";"// This handles Cents";if contains(text(numAmount), ".") thenlet dpIndex := index(text(numAmount), ".");let numCents := number(substr(text(numAmount), dpIndex + 1, 2));NtW := "and " + numberToWord(mod(numCents, 100), "Cents") + " usd"end;"// This handles digits at Ones and Tens place";NtW := numberToWord(mod(numAmount, 100), "") + NtW;"// This handles digit at Hundreds place";NtW := numberToWord(mod(numAmount / 100, 10), "Hundred ") + NtW;"// This handles digits at One Thousands and Ten Thousands place";NtW := numberToWord(mod(numAmount / 1000, 100), "Thousand ") + NtW;"// This handles digit at Hundred Thousands place";NtW := numberToWord(mod(numAmount / 100000, 10), "Hundred ") + NtW;"// This handles digits at One Millions and Ten Millions place";NtW := numberToWord(mod(numAmount / 1000000, 100), "Million ") + NtW;"// This handles digit at Hundred Millions place";NtW := numberToWord(mod(numAmount / 100000000, 10), "Hundred ") + NtW;"// This handles digit at One Billions place";NtW := numberToWord(mod(numAmount / 1000000000, 10), "Billion ") + NtW;NtWelse"Number is too large"end`

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

For anyone who is interested in output of the mod() function here is a mockup spreadsheet:

Like
• New Sun
• New_Sun
• 4 yrs ago
• Reported - view

yes, it is correct, Ninox is best programs i've ever seen. really thank you.

Like
• New Sun
• New_Sun
• 4 yrs ago
• Reported - view

i am testing the formula for all numbers.

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

You’re welcome. I agree Ninox is pretty amazing. It’s going to be interesting to see what areas they focused on when they release the next update.

Like
• New Sun
• New_Sun
• 4 yrs ago
• Reported - view

I tested them, there is one problem on 19,175usd. Result is : nine thousand one hundred seventy five. While should be :nineteen not nine.

also i tested on 19000usd and result was correct (nineteen)

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

This should take care of that problem. It also checks for 0 cents so the "and" won't be displayed in that case.

`let empty := "";let x := [empty, "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "];let y := [empty, empty, "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "];"/*                       ";" * User defined functions";" */                      ";function mod(dividend : number,divisor : number) dodividend - divisor * floor(dividend / divisor)end;function numberToWord(num : number,suffix : text) doif floor(num) != 0 thenif floor(num) > 19 thenitem(y, floor(num / 10)) + item(x, mod(num, 10)) + suffixelseitem(x, num) + suffixendelseemptyendend;"/*             ";" * Main program";" */            ";"// Number to be converted to words";let numAmount := Net;"// Test for number of digits";if length(format(floor(numAmount), "0")) < 11 then"// String to store word representation of given number";let NtW := "";"// This handles Cents";if contains(text(numAmount), ".") thenlet dpIndex := index(text(numAmount), ".");let numCents := number(substr(text(numAmount), dpIndex + 1, 2));if numCents > 0 thenNtW := "and " + numberToWord(mod(numCents, 100), "Cents") + " usd"elseNtW := "usd"endend;"// This handles digits at Ones and Tens place";NtW := numberToWord(mod(numAmount, 100), "") + NtW;"// This handles digit at Hundreds place";NtW := numberToWord(mod(numAmount / 100, 10), "Hundred ") + NtW;"// This handles digits at One Thousands and Ten Thousands place";NtW := numberToWord(mod(numAmount / 1000, 100), "Thousand ") + NtW;"// This handles digit at Hundred Thousands place";NtW := numberToWord(mod(numAmount / 100000, 10), "Hundred ") + NtW;"// This handles digits at One Millions and Ten Millions place";NtW := numberToWord(mod(numAmount / 1000000, 100), "Million ") + NtW;"// This handles digit at Hundred Millions place";NtW := numberToWord(mod(numAmount / 100000000, 10), "Hundred ") + NtW;"// This handles digit at One Billions place";NtW := numberToWord(mod(numAmount / 1000000000, 10), "Billion ") + NtW;NtWelse"Number is too large"end`

Like
• New Sun
• New_Sun
• 4 yrs ago
• Reported - view

yes, this is correct. thank you.

Like
• thank for this post it,s wery handy and helpful. jus wondering is it posible to make this formula to spelll number to nearest cent.

ex (Two Thousand Nine Hundred Thirteen Euro and Fifty Seven Cents )

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

The last code post on page 4 does this (next to last post).

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

This code adjusts for Euros and tests for 0.00

`let empty := "";let x := [empty, "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "];let y := [empty, empty, "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "];"/*                       ";" * User defined functions";" */                      ";function mod(dividend : number,divisor : number) dodividend - divisor * floor(dividend / divisor)end;function numberToWord(num : number,suffix : text) doif floor(num) != 0 thenif floor(num) > 19 thenitem(y, floor(num / 10)) + item(x, mod(num, 10)) + suffixelseitem(x, num) + suffixendelseemptyendend;"/*             ";" * Main program";" */            ";"// Number to be converted to words";let numAmount := Net;"// Test for number of digits";if length(format(floor(numAmount), "0")) < 11 then"// String to store word representation of given number";let NtW := "";"// This handles Cents";if contains(text(numAmount), ".") thenlet dpIndex := index(text(numAmount), ".");let numCents := number(substr(text(numAmount), dpIndex + 1, 2));if floor(numAmount) > 0 then NtW := "and " end;if numCents > 0 thenNtW := NtW + numberToWord(mod(numCents, 100), "Cents")elseif floor(numAmount) > 0 thenNtW := NtW + "no Cents"elseNtW := ""endendend;if floor(numAmount) > 0 then NtW := "Euro " + NtW end;"// This handles digits at Ones and Tens place";NtW := numberToWord(mod(numAmount, 100), "") + NtW;"// This handles digit at Hundreds place";NtW := numberToWord(mod(numAmount / 100, 10), "Hundred ") + NtW;"// This handles digits at One Thousands and Ten Thousands place";NtW := numberToWord(mod(numAmount / 1000, 100), "Thousand ") + NtW;"// This handles digit at Hundred Thousands place";NtW := numberToWord(mod(numAmount / 100000, 10), "Hundred ") + NtW;"// This handles digits at One Millions and Ten Millions place";NtW := numberToWord(mod(numAmount / 1000000, 100), "Million ") + NtW;"// This handles digit at Hundred Millions place";NtW := numberToWord(mod(numAmount / 100000000, 10), "Hundred ") + NtW;"// This handles digit at One Billions place";NtW := numberToWord(mod(numAmount / 1000000000, 10), "Billion ") + NtW;NtWelse"Number is too large"end`

Like
• Good evening.

I have tried this formula unfortunately it only spells the amount without cent can this be an issue because of wrong decimals as at the moment my separation is a , ant formula only understands numbers as cents after . ?

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

Yes, the current code checks for "." as the decimal separator. What symbol do you use for the thousands separator? How many digits to the right of the decimal separator do you use?

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

Also, do you use Euro or Euros for more than 1?

Like
• Good day,

At the moment i use Euro.  I use two decimas. fot thausand seperator i use "," but i supose that ninox takes that from macbook setings. i changed the seperator sign in formula and it works well now. just wondering is is posible to show thausiand hundres etc in words and cents in numbers ex (Two thausiand eight huntret thirty euro and 57 cent ). as in my countrys ammount in words should be in this order.

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

Hello,

Would you please post the formula you use to produce the number with comma decimal separator. I tried to do it with the format() function and it's not working.

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

Can't see the forest for the trees department... Since Ninox does not store numbers with a "," as a decimal separator, you would be converting from a number that already exists in your database, right? You could just use that number in the Number to Words code. If it is the result of a calculation, you can just change:

`let numAmount := Net;`

to: let numAmount := yourCalculation

Like
• Nick
• Nick
• 4 yrs ago
• Reported - view

@slowwagon

For "Total to Words" I'm using -> let numAmount := 'Invoice Total';

For "Total to Words cents" I'm using -> let numAmount := Subtotal + 'Tax Amount' - 'Discount €' + Shipping;

Thanks for sharing!

Nick

Like
• Sean
• Sean
• 4 yrs ago
• Reported - view

Hi Nick,

I'm happy to contribute. Do the non-English versions of Ninox allow the storage of numbers using "," as the decimal separator? If so, what is the thousands, or grouping, separator? If the grouping separator is not the same as the decimal separator, it should be an easy fix. Otherwise, I'll need to figure out a different way to separate integers from decimals.

The most recent version of the code is posted on page 5 and it does not display cents as a fraction. Also, what is more common Euro or Euros for plural? I did search on that topic and there does not appear to be a consensus in that regard. I'll be driving most of the day so I won't be able to respond until later.

Sean

Like
Like Follow
• 2 yrs agoLast active
• 68Replies
• 16311Views