Change

Ninox Profile

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

Ninox Profile

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) do
dividend - divisor * floor(dividend / divisor)
end;
function numberToWord(num : number,suffix : text) do
if floor(num) != 0 then
if num > 19 then
item(y, floor(num / 10)) + item(x, mod(num, 10)) + suffix
else
item(x, num) + suffix
end
else
empty
end
end;
"/*             ";
" * 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), ".") then
let 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;
NtW
else
"Number is too large"
end

Ninox Profile

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) do
dividend - divisor * floor(dividend / divisor)
end;
function numberToWord(num : number,suffix : text) do
if floor(num) != 0 then
if num > 19 then
item(y, floor(num / 10)) + item(x, mod(num, 10)) + suffix
else
item(x, num) + suffix
end
else
empty
end
end;
"/*             ";
" * 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), ".") then
let 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;
NtW
else
"Number is too large"
end

Ninox Profile

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

 

Screen Shot 2018-11-03 at 8.49.41 PM

Ninox Profile

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

Ninox Profile

i am testing the formula for all numbers.

Ninox Profile

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.

Ninox Profile

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)

 

F00AAFF1-83B7-47C8-9ED0-D8100402D994

Ninox Profile

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) do
dividend - divisor * floor(dividend / divisor)
end;
function numberToWord(num : number,suffix : text) do
if floor(num) != 0 then
if floor(num) > 19 then
item(y, floor(num / 10)) + item(x, mod(num, 10)) + suffix
else
item(x, num) + suffix
end
else
empty
end
end;
"/*             ";
" * 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), ".") then
let dpIndex := index(text(numAmount), ".");
let numCents := number(substr(text(numAmount), dpIndex + 1, 2));
if numCents > 0 then
NtW := "and " + numberToWord(mod(numCents, 100), "Cents") + " usd"
else
NtW := "usd"
end
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;
NtW
else
"Number is too large"
end

Ninox Profile

yes, this is correct. thank you.

Reply