# Number to Text Routine?

Wayne Germann wgermann at PACIFIC.EDU
Fri Jul 22 20:46:51 UTC 2022

```Sorry for the sloppy formatting...  I tried to clean it up

-----Original Message-----
From: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> On Behalf Of Wayne Germann
Sent: Friday, July 22, 2022 1:42 PM
To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
Subject: RE: Number to Text Routine?

Put this code inside the field you type the dollar amount in numbers.

On evAfter     ;; Event Parameters - pClickedField, pClickedWindow, pMenuLine, pCommandNumber, pRow
Do Money.\$ConvertMoney(F_CHECKS.F_CHK_AMOUNT) Returns %%MoneyString
Calculate F_CHECKS.F_CHK_AMT_TEXT as %%MoneyString
Do \$cwind.\$redraw()

I created an object with the "Money.\$ConvertMoney" procedure.  Here is the procedure:

;  convert two decimal number to string for check writing Calculate moneyString as ''
Calculate thousands as int(moneyAmount/1000)
Calculate hundreds as int(mod(moneyAmount,1000)/100)
Calculate units as mod(int(moneyAmount),100)
Calculate pennies as mod(moneyAmount*100,100)
If thousands>19 Calculate moneyString as con(moneyString,pick(int(thousands/10),'','','Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety'),' ')
Calculate moneyString as con(moneyString,pick(mod(thousands,10),'','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'),' ') Calculate moneyString as con(moneyString,'Thousand ')
Else If thousands>9 Calculate moneyString as con(moneyString,pick(thousands-10,'Ten','Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen','Seventeen','Eighteen','Nineteen'),' Thousand ')
Else If thousands Calculate moneyString as con(moneyString,pick(thousands,'','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'),' Thousand ')
End If
If hundreds Calculate moneyString as con(moneyString,pick(hundreds,'','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'),' Hundred ')
End If
If units>19 Calculate moneyString as con(moneyString,pick(int(units/10),'','','Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety'),' ')
Calculate moneyString as con(moneyString,pick(mod(units,10),'','One ','Two ','Three ','Four ','Five ','Six ','Seven ','Eight ','Nine '))
Else If units>9 Calculate moneyString as con(moneyString,pick(units-10,'Ten','Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen','Seventeen','Eighteen','Nineteen'),' ') Else Calculate moneyString as con(moneyString,pick(units,'','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'),' ')
End If If moneyAmount<1 Calculate moneyString as 'Zero '
End If
If not(pennies)
Calculate moneyString as con(moneyString,'and no/100')
Else Calculate moneyString as con(moneyString,'and ',pennies,'/100')
End If Quit method moneyString

-----Original Message-----
From: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> On Behalf Of Das Goravani
Sent: Friday, July 22, 2022 12:50 PM
To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
Subject: Number to Text Routine?

CAUTION: This email originated from outside of Pacific. Do not click any links or open attachments if this is unsolicited email.

Hello All,

One thing I’m working on is the printing of checks.

It’s one thing to have the amount as a number, that’s normal, but to print the check I need the amount in text like:

One Thousand Seven Hundred Thirty Four and 68 cents

Does anyone have a routine that does this conversion ?

I think I could write one, but it would be a bit long, someone might do it smarter than I could do it.

Thanks

Das Goravani
_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
```