[I7] Capitalizing numbers in words - SOLVED

I want to start off a sentence with a number in words:

say "[trophieno in words] trophies are displayed in the cabinet."

but I can’t figure out how to capitalize it. Is there an easy way to do it?

Thank you in advance, you guys are amazing.

Quick and dirty method of doing it. I suspect you could do it without the intermediary steps, but as I’m in a hurry, this will have to do. :confused:

To say (n - number) in sentence-cased words: let i be indexed text; let i be "[n in words]"; say "[i in sentence case]";

Usage:

"[trophieno in sentence-cased words] troph[if trophieno is 1]y is[otherwise]ies are[end if] displayed in the cabinet."

Try this.

To say (N - number) in capitalised words: let result be an indexed text; now result is "[N in words]"; say result in sentence case.

You can see it in action here.

This capitalised words code is courtesy of zarf.

Hope this helps.

Oops! Just realised that it’s exactly the same as Eleas’s code! :blush:

Solved! I tried to mess around with sentence-cased, but I just couldnt make it work. Thanks for being a hero.

Oh, zarf made one as well? Huh. I half thought he’d find a way to create the same effect using only the tilde sign or something.

What I would actually do is write a whole new set of I6 routines to print capitalized numbers, without using indexed text. Slightly faster, much harder to understand.

The lesson here is, don’t do what I would do. :slight_smile:

You mean something like this?

[spoiler][code]Include (-

[ CapitalisedLanguageNumber n f k;
k = 1;
if (n == 0) { print “Zero”; rfalse; }
if (n < 0) { print "Minus "; n = -n; k = 0; }
#Iftrue (WORDSIZE == 4);
if (n >= 1000000000) {
if (f == 1) print ", “;
if (k == 1) {
print (CapitalisedLanguageNumber) n/1000000000;
k = 0;
}
else {
print (LanguageNumber) n/1000000000;
}
print " billion”; n = n%1000000000; f = 1;
}
if (n >= 1000000) {
if (f == 1) print ", “;
if (k == 1) {
print (CapitalisedLanguageNumber) n/1000000;
k = 0;
}
else {
print (LanguageNumber) n/1000000;
}
print " million”; n = n%1000000; f = 1;
}
#Endif;
if (n >= 1000) {
if (f == 1) print ", “;
if (k == 1) {
print (CapitalisedLanguageNumber) n/1000;
k = 0;
}
else {
print (LanguageNumber) n/1000;
}
print " thousand”; n = n%1000; f = 1;
}
if (n >= 100) {
if (f == 1) print ", “;
if (k == 1) {
print (CapitalisedLanguageNumber) n/100;
k = 0;
}
else {
print (LanguageNumber) n/100;
}
print " hundred”; n = n%100; f = 1;
}
if (n == 0) rfalse;
#Ifdef DIALECT_US;
if (f == 1) print " ";
#Ifnot;
if (f == 1) print " and ";
#Endif;
if (k == 1) {
switch (n) {
1: print “One”;
2: print “Two”;
3: print “Three”;
4: print “Four”;
5: print “Five”;
6: print “Six”;
7: print “Seven”;
8: print “Eight”;
9: print “Nine”;
10: print “Ten”;
11: print “Eleven”;
12: print “Twelve”;
13: print “Thirteen”;
14: print “Fourteen”;
15: print “Fifteen”;
16: print “Sixteen”;
17: print “Seventeen”;
18: print “Eighteen”;
19: print “Nineteen”;
20 to 99: switch (n/10) {
2: print “Twenty”;
3: print “Thirty”;
4: print “Forty”;
5: print “Fifty”;
6: print “Sixty”;
7: print “Seventy”;
8: print “Eighty”;
9: print “Ninety”;
}
if (n%10 ~= 0) print “-”, (LanguageNumber) n%10;
}
k = 0;
}
else {
switch (n) {
1: print “one”;
2: print “two”;
3: print “three”;
4: print “four”;
5: print “five”;
6: print “six”;
7: print “seven”;
8: print “eight”;
9: print “nine”;
10: print “ten”;
11: print “eleven”;
12: print “twelve”;
13: print “thirteen”;
14: print “fourteen”;
15: print “fifteen”;
16: print “sixteen”;
17: print “seventeen”;
18: print “eighteen”;
19: print “nineteen”;
20 to 99: switch (n/10) {
2: print “twenty”;
3: print “thirty”;
4: print “forty”;
5: print “fifty”;
6: print “sixty”;
7: print “seventy”;
8: print “eighty”;
9: print “ninety”;
}
if (n%10 ~= 0) print “-”, (LanguageNumber) n%10;
}
}
];

-).

To say (something - a number) in capitalised words: (- print (CapitalisedLanguageNumber) {something}; -).[/code][/spoiler]

Yes, that looks like what I’d do.

Too late for me to not do it now! :laughing: