[I7] I6 inclusion and abject failure

[code]To ordinalize (something - number): (- SayOrdinal(something); -).

Include (-
[ SayOrdinal n f;
if (n == 0) { print “zeroth”; rfalse; }
if (n < 0) { print "minus “; n = -n; }
if (n >= 1000) { print (LanguageNumber) n/1000, " thousand”; n = n%1000; f = 1; }
if (n >= 100) {
if (f == 1) print ", “;
print (LanguageNumber) n/100, " hundred”; n = n%100; f = 1;
}
if (n == 0) rfalse;
#Ifdef DIALECT_US;
if (f == 1) print " ";
#Ifnot;
if (f == 1) print " and ";
#Endif;
switch (n) {
1: print “first”;
2: print “second”;
3: print “third”;
4: print “four”;
5: print “fif”;
6: print “six”;
7: print “seven”;
8: print “eigh”;
9: print “nin”;
10: print “ten”;
11: print “eleven”;
12: print “twelf”;
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 “-”, (LanNum) n%10;
}
if (n>3) print “th”;
];
-).
[/code]

This fails when invoked. If you invoke

To ordinalize (something - number): (- SayOrdinal(12); -).

however, it works as intended, so it seems I’m doing something wrong when passing the number to the routine. However, I can’t see what.

Ack. Never mind, I think I got it. :blush:

EDIT: and it still doesn’t work. This is really strange.

How does it fail?

You need curly brackets around the name of the passee:

To ordinalize (N - number): (- SayOrdinal({N}); -).

–Erik

Thank you. :slight_smile:

It doesn’t seem to display certain numbers correctly. It says “twentyth” rather than “twentieth”, “twenty oneth” rather than “twenty first” and “one hundred” rather than “one hundredth”.

This is the code I use.

[spoiler][code][ OrdinalNumber n f;
if (n == 0) { print “zeroth”; rfalse; }
if (n < 0) { print "minus "; n = -n; }
#Iftrue (WORDSIZE == 4);
if (n >= 1000000000) {
if (f == 1) print ", “;
print (LanguageNumber) n/1000000000, " billion”; n = n%1000000000; f = 1;
}
if (n >= 1000000) {
if (f == 1) print ", “;
print (LanguageNumber) n/1000000, " million”; n = n%1000000; f = 1;
}
#Endif;
if (n >= 1000) {
if (f == 1) print ", “;
print (LanguageNumber) n/1000, " thousand”; n = n%1000; f = 1;
}
if (n >= 100) {
if (f == 1) print ", “;
print (LanguageNumber) n/100, " hundred”; n = n%100; f = 1;
}
if (n == 0) {
print “th”;
rfalse;
}
if (f == 1) print " and ";
switch (n) {
1: print “first”;
2: print “second”;
3: print “third”;
4: print “fourth”;
5: print “fifth”;
6: print “sixth”;
7: print “seventh”;
8: print “eighth”;
9: print “ninth”;
10: print “tenth”;
11: print “eleventh”;
12: print “twelveth”;
13: print “thirteenth”;
14: print “fourteenth”;
15: print “fifteenth”;
16: print “sixteenth”;
17: print “seventeenth”;
18: print “eighteenth”;
19: print “nineteenth”;
20 to 99: switch (n/10) {
2: print “twent”;
3: print “thirt”;
4: print “fort”;
5: print “fift”;
6: print “sixt”;
7: print “sevent”;
8: print “eight”;
9: print “ninet”;
}
if (n%10 ~= 0) {
print "y ", (OrdinalNumber) n%10;
}
else {
print “ieth”;
}
}
];

-).

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

Hope this helps.

Thanks, climbingstars. I did refactor after Erik’s post made it possible, but I decided to make it an I7 routine instead. That actually turned out to be easier and kept things purely I7. It also let me manipulate the result as indexed text, which I’m not sure is as easy with I6 print statements, although I may be wrong on that score.