Aw shucks, I'm a sucker for folk that ask nice.
I don't recall if CR 8.0 English has loop and ubound functionality. If it does, you could use them for a shorter version of what will otherwise turn out to be a very long formula for you.
I'm going to get you rolling with a cut-and-paste montage of a formula which'll get you converting numbers up to 99,999.
Let's get started then; it's about to get spammy in here:
//@ToWords Start
WhilePrintingRecords;
StringVar Amount := ToText({YourCurrencyOrNumberField},0,'');
//If you want to take decimals into account, switch 0 for 2.
//You'll then need to tweak the following a little.
NumberVar AmountLength;
StringVar SmallChange;
NumberVar SmallChangeLength;
//Use copies of AmountLength = 2 sections, but start from '.'+1 to derive the SmallChange values.
Local StringVar One;
Local StringVar Two;
Local StringVar Three;
Local StringVar Four;
Local StringVar Five;
If Instr(Amount,'.') > 0
Then AmountLength := Length(Mid(Amount,1,Instr(Amount,'.')))
Else AmountLength := Length(Amount);
If Instr(Amount,'.') > 0
Then SmallChangeLength := Length(Mid(Amount,Instr(Amount,'.')+1))
Else SmallChangeLength := 0;
//Continue SmallChange here or in another formula to handle decimals.
If AmountLength = 1
Then
(Select Amount
Case '0' : One := 'Zero'
Case '1' : One := 'One'
Case '2' : One := 'Two'
Case '3' : One := 'Three'
Case '4' : One := 'Four'
Case '5' : One := 'Five'
Case '6' : One := 'Six'
Case '7' : One := 'Seven'
Case '8' : One := 'Eight'
Case '9' : One := 'Nine'
End);
If AmountLength = 2
Then
If Mid(Amount,1,1) = '1'
Then
(Select Amount
Case '10' : Two := Two + 'Ten'
Case '11' : Two := Two + 'Eleven'
Case '12' : Two := Two + 'Twelve'
Case '13' : Two := Two + 'Thirteen'
Case '14' : Two := Two + 'Fourteen'
Case '15' : Two := Two + 'Fifteen'
Case '16' : Two := Two + 'Sixteen'
Case '17' : Two := Two + 'Seventeen'
Case '18' : Two := Two + 'Eighteen'
Case '19' : Two := Two + 'Nineteen'
End)
Else
(Select Mid(Amount,1,1)
Case '2' : Two := Two + 'Twenty'
Case '3' : Two := Two + 'Thirty'
Case '4' : Two := Two + 'Forty'
Case '5' : Two := Two + 'Fifty'
Case '6' : Two := Two + 'Sixty'
Case '7' : Two := Two + 'Seventy'
Case '8' : Two := Two + 'Eighty'
Case '9' : Two := Two + 'Ninety'
End);
If AmountLength = 2 and Mid(Amount,1,1) <> '1'
Then
(Select Mid(Amount,2,1)
Case '0' : Two := Two
Case '1' : Two := Two + ' one'
Case '2' : Two := Two + ' two'
Case '3' : Two := Two + ' three'
Case '4' : Two := Two + ' four'
Case '5' : Two := Two + ' five'
Case '6' : Two := Two + ' six'
Case '7' : Two := Two + ' seven'
Case '8' : Two := Two + ' eight'
Case '9' : Two := Two + ' nine'
End);
If AmountLength = 3
Then
(Select Mid(Amount,1,1)
Case '1' : Three := Three + 'One'
Case '2' : Three := Three + 'Two'
Case '3' : Three := Three + 'Three'
Case '4' : Three := Three + 'Four'
Case '5' : Three := Three + 'Five'
Case '6' : Three := Three + 'Six'
Case '7' : Three := Three + 'Seven'
Case '8' : Three := Three + 'Eight'
Case '9' : Three := Three + 'Nine'
End);
If AmountLength = 3 and Mid(Amount,2,2) = '00'
Then Three := Three + ' hundred'
Else
If AmountLength = 3 and Mid(Amount,2,2) <> '00'
Then Three := Three + ' hundred and';
If AmountLength = 3
Then
If Mid(Amount,2,1) = '1'
Then
(Select Mid(Amount,2,2)
Case '10' : Three := Three + ' ten'
Case '11' : Three := Three + ' eleven'
Case '12' : Three := Three + ' twelve'
Case '13' : Three := Three + ' thirteen'
Case '14' : Three := Three + ' fourteen'
Case '15' : Three := Three + ' fifteen'
Case '16' : Three := Three + ' sixteen'
Case '17' : Three := Three + ' seventeen'
Case '18' : Three := Three + ' eighteen'
Case '19' : Three := Three + ' nineteen'
End)
Else
(Select Mid(Amount,2,1)
Case '2' : Three := Three + ' twenty'
Case '3' : Three := Three + ' thirty'
Case '4' : Three := Three + ' forty'
Case '5' : Three := Three + ' fifty'
Case '6' : Three := Three + ' sixty'
Case '7' : Three := Three + ' seventy'
Case '8' : Three := Three + ' eighty'
Case '9' : Three := Three + ' ninety'
End);
If AmountLength = 3 and Mid(Amount,2,1) <> '1'
Then
(Select Mid(Amount,3,1)
Case '0' : Three := Three
Case '1' : Three := Three + ' one'
Case '2' : Three := Three + ' two'
Case '3' : Three := Three + ' three'
Case '4' : Three := Three + ' four'
Case '5' : Three := Three + ' five'
Case '6' : Three := Three + ' six'
Case '7' : Three := Three + ' seven'
Case '8' : Three := Three + ' eight'
Case '9' : Three := Three + ' nine'
End);
If AmountLength = 4
Then
(Select Mid(Amount,1,1)
Case '1' : Four := Four + 'One'
Case '2' : Four := Four + 'Two'
Case '3' : Four := Four + 'Three'
Case '4' : Four := Four + 'Four'
Case '5' : Four := Four + 'Five'
Case '6' : Four := Four + 'Six'
Case '7' : Four := Four + 'Seven'
Case '8' : Four := Four + 'Eight'
Case '9' : Four := Four + 'Nine'
End);
If AmountLength = 4 and Mid(Amount,2,1) = '0'
Then Four := Four + ' thousand and'
Else
If AmountLength = 4
Then Four := Four + ' thousand,';
If AmountLength = 4
Then
(Select Mid(Amount,2,1)
Case '1' : Four := Four + ' one'
Case '2' : Four := Four + ' two'
Case '3' : Four := Four + ' three'
Case '4' : Four := Four + ' four'
Case '5' : Four := Four + ' five'
Case '6' : Four := Four + ' six'
Case '7' : Four := Four + ' seven'
Case '8' : Four := Four + ' eight'
Case '9' : Four := Four + ' nine'
End);
If AmountLength = 4 and Mid(Amount,2,1) = '0'
Then Four
Else
If AmountLength = 4 and Mid(Amount,3,2) = '00'
Then Four := Four + ' hundred'
Else
If AmountLength = 4 and Mid(Amount,3,2) <> '00'
Then Four := Four + ' hundred and';
If AmountLength = 4
Then
If Mid(Amount,3,1) = '1'
Then
(Select Mid(Amount,3,2)
Case '10' : Four := Four + ' and ten'
Case '11' : Four := Four + ' and eleven'
Case '12' : Four := Four + ' and twelve'
Case '13' : Four := Four + ' and thirteen'
Case '14' : Four := Four + ' and fourteen'
Case '15' : Four := Four + ' and fifteen'
Case '16' : Four := Four + ' and sixteen'
Case '17' : Four := Four + ' and seventeen'
Case '18' : Four := Four + ' and eighteen'
Case '19' : Four := Four + ' and nineteen'
End)
Else
(Select Mid(Amount,3,1)
Case '2' : Four := Four + ' twenty'
Case '3' : Four := Four + ' thirty'
Case '4' : Four := Four + ' forty'
Case '5' : Four := Four + ' fifty'
Case '6' : Four := Four + ' sixty'
Case '7' : Four := Four + ' seventy'
Case '8' : Four := Four + ' eighty'
Case '9' : Four := Four + ' ninety'
End);
If AmountLength = 4 and Mid(Amount,3,1) <> '1'
Then
(Select Mid(Amount,4,1)
Case '0' : Four := Four
Case '1' : Four := Four + ' one'
Case '2' : Four := Four + ' two'
Case '3' : Four := Four + ' three'
Case '4' : Four := Four + ' four'
Case '5' : Four := Four + ' five'
Case '6' : Four := Four + ' six'
Case '7' : Four := Four + ' seven'
Case '8' : Four := Four + ' eight'
Case '9' : Four := Four + ' nine'
End);
If AmountLength = 5
Then
(Select Mid(Amount,1,2)
Case '10' : Five := Five + 'Ten'
Case '11' : Five := Five + 'Eleven'
Case '12' : Five := Five + 'Twelve'
Case '13' : Five := Five + 'Thirteen'
Case '14' : Five := Five + 'Fourteen'
Case '15' : Five := Five + 'Fifteen'
Case '16' : Five := Five + 'Sixteen'
Case '17' : Five := Five + 'Seventeen'
Case '18' : Five := Five + 'Eighteen'
Case '19' : Five := Five + 'Nineteen'
End);
If AmountLength = 5 and Mid(Amount,3,1) = '0'
Then Five := Five + ' thousand and'
Else
If AmountLength = 5
Then Five := Five + ' thousand,';
If AmountLength = 5
Then
(Select Mid(Amount,3,1)
Case '1' : Five := Five + ' one'
Case '2' : Five := Five + ' two'
Case '3' : Five := Five + ' three'
Case '4' : Five := Five + ' four'
Case '5' : Five := Five + ' five'
Case '6' : Five := Five + ' six'
Case '7' : Five := Five + ' seven'
Case '8' : Five := Five + ' eight'
Case '9' : Five := Five + ' nine'
End);
If AmountLength = 5 and Mid(Amount,3,1) = '0'
Then Five
Else
If AmountLength = 5 and Mid(Amount,4,2) = '00'
Then Five := Five + ' hundred'
Else
If AmountLength = 5 and Mid(Amount,4,2) <> '00'
Then Five := Five + ' hundred and';
If AmountLength = 5
Then
If Mid(Amount,4,1) = '1'
Then
(Select Mid(Amount,4,2)
Case '10' : Five := Five + ' and ten'
Case '11' : Five := Five + ' and eleven'
Case '12' : Five := Five + ' and twelve'
Case '13' : Five := Five + ' and thirteen'
Case '14' : Five := Five + ' and fourteen'
Case '15' : Five := Five + ' and fifteen'
Case '16' : Five := Five + ' and sixteen'
Case '17' : Five := Five + ' and seventeen'
Case '18' : Five := Five + ' and eighteen'
Case '19' : Five := Five + ' and nineteen'
End)
Else
(Select Mid(Amount,4,1)
Case '2' : Five := Five + ' twenty'
Case '3' : Five := Five + ' thirty'
Case '4' : Five := Five + ' forty'
Case '5' : Five := Five + ' fifty'
Case '6' : Five := Five + ' sixty'
Case '7' : Five := Five + ' seventy'
Case '8' : Five := Five + ' eighty'
Case '9' : Five := Five + ' ninety'
End);
If AmountLength = 5 and Mid(Amount,4,1) <> '1'
Then
(Select Mid(Amount,5,1)
Case '0' : Five := Five
Case '1' : Five := Five + ' one'
Case '2' : Five := Five + ' two'
Case '3' : Five := Five + ' three'
Case '4' : Five := Five + ' four'
Case '5' : Five := Five + ' five'
Case '6' : Five := Five + ' six'
Case '7' : Five := Five + ' seven'
Case '8' : Five := Five + ' eight'
Case '9' : Five := Five + ' nine'
End);
If Length(Five) = 0 Then
If Length(Four) = 0 Then
If Length(Three) = 0 Then
If Length(Two) = 0
Then One
Else Two
Else Three
Else Four
Else Five;
//@ToWords End
etc, etc. You get the drift, I'm sure. Like I say, this example will get you up to 1 shy of 100,000. You can follow the same ideal to take you up to 6 and 7 figure numbers if it's likely your current data will take you up that far.
I'll leave the converting from English to Portuguese to you,
porque eu não falo o português muito bem...
Boa sorte,
Naith