- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Numbers -> Words for Check Printing
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2001 05:49 PM
тАО12-06-2001 05:49 PM
Our Finance Department has just purchased a new printer and check forms. Of course, no one in IT was contacted until after the fact. The check format is supposed to be identical to our old form. Of course, now we want some 'minor changes' and we don't have the source code. The vendor wants several thousand dollars for this change and 3 months. I would like to write a filter which grabs the output before sending it to lp. The changes actually aren't all that big except for one that is very difficult for me. Currently, the amount (on line 24) prints like 9145.50 and then on line 30 like '9145 and 50/100'. We would like the amount to print like '$*******9,145.50' (with comma's) and 'Nine thousand one hundred fourty-five and 50/100'. I think I can put the comma's in the amounts but the numbers to words conversion has me baffled. The actual format is very simple, each check is 48 lines long and everything except lines 24 and 30 can pass unchanged. The new printer also needs a formfeed every page to trigger the fold and seal operation but that I can do. I've attached a sample file. Any ideas are welcome and points will be given. I'll take anything, awk, C, sed, shell scripts. Please help!!!
Thanks, Doug
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2001 06:16 PM
тАО12-06-2001 06:16 PM
Re: Numbers -> Words for Check Printing
An interesting problem. I love it when things like that on sprung on me. The good news is that I have a C routine that I have used for over twenty years to do the numbers -> english conversion.
You use it like this:
english_numbers(345.12,s_tmp,60)
That will format the string s_tmp up a maximum of 60 characters like "Three hundred fourty five and 12/100". To be safe, I would declare s_tmp[128] or so.
Have fun, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2001 06:26 PM
тАО12-06-2001 06:26 PM
Re: Numbers -> Words for Check Printing
I don't normally do this but this is an interesting one. I think I can translate that C routine into Perl in under 20 minutes. There is a Perl module that is fairly close but I think I'll translate my C routine. I know the commas and stars will be a piece of cake. I should be able to throw everything together by sometime AM CST. I actually have all the pieces except for the english_numbers I just have to put them together.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2001 07:18 PM
тАО12-06-2001 07:18 PM
SolutionThe Perl version was a snap. I think you will be amazed at the execution speed especially when compared to awk. I managed to throw in your formfeeds and commas as well. The commify
was lifted from an O'Reilly 'Perl Cookbook' example. It illustrates Perl at its best and worst. This guy reverses the string since processing and looking for the decimal is easier; does some in-place editing; and then reverse the string again for output. Believe it or not, that stuff begin to make sense after a bit. You will probably have to play just a little to get the horizontal positioning of the two modified lines correct. Just change the "%50s" in the format string to "%48s" or whatever. Other than that your there. Rather than the thousand of dollars your vendor wanted, I'll settle for a few hundred.
Last note: This guy is a filter so it expects you to feed it with stdin and it simply writes to stdout.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2001 09:49 PM
тАО12-06-2001 09:49 PM
Re: Numbers -> Words for Check Printing
Well ... I was gonna suggest using awk with the sub or gsub function, something like
echo 9865 | awk '{ gsub(9,"nine "); gsub(8,"eight "); print }'
Which would still leave some problems ...
but then I read Clay's answer ... and felt
rather stupid.
Doug, give him points from me as well ... if
you would be so kind ...
Tom Geudens
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2001 03:30 AM
тАО12-07-2001 03:30 AM
Re: Numbers -> Words for Check Printing
Hope this helps,
Regards,
Suhas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2001 12:32 PM
тАО12-07-2001 12:32 PM
Re: Numbers -> Words for Check Printing
Clay, I hate to ask but now they are so pleased with 'my' work that they found this small problem that they just know I can fix. "Doug, can you put the hyphen in fourty-five?" Can you at least give me a hint? Your perl script looks easy but everytime I start trying to put in the hyphens I get lost.
Sorry, it took me so long to assign points. I got started and then couldn't get back in to the Forums.
Again, thanks to all!!!
Doug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2001 12:41 PM
тАО12-07-2001 12:41 PM
Re: Numbers -> Words for Check Printing
I don't know perl, but that would appear to be the place to do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2001 12:48 PM
тАО12-07-2001 12:48 PM
Re: Numbers -> Words for Check Printing
I'm glad you liked it. As for those hyphens, I think that is 'too much sugar for a dime'. I will give you a hint. If you look for /ty / that will get you started but the rules get complex rather quickly. Besides us dumb folks in Mississippi do know nothing about no hyphens nohow. I'm not even sure (and really don't care) if it's "One hundred fourty-four thousand fourty-four and 44/100" or "One hundred fourty four thousand fourty-four and 44/100". Maybe some of them educated folks knows the answer but I sure don't. Anyway, if you (or some other nosey-body) can find the answer then MAYBE I'll think about it. I got me a new Perl module and that's all I care about. You can tell them folk's in the Finance Dept. who worries about them there hyphens to get a life.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2001 12:58 PM
тАО12-07-2001 12:58 PM
Re: Numbers -> Words for Check Printing
"One hundred fourty-five" gets one but "One hundred fourty" does not. It gets worse if the thousands or millions also are supposed to get them there hyphens (what we call dashes) as well.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2001 01:25 PM
тАО12-07-2001 01:25 PM
Re: Numbers -> Words for Check Printing
My experts tell me that 'fourty-five' gets a hyphen each time in the amount string. Please help.
Patrick,
Thanks, I tried that first but as Clay pointed out that doesn't quite work.
Doug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2001 04:45 PM
тАО12-07-2001 04:45 PM
Re: Numbers -> Words for Check Printing
I spent about 10 minutes after work adding your dumb ole hyphens. I probably didn't code this like a real Perl programmer but rather like a C/C++ guy would. The hyphen stuff is commented a bit to help. If was really an easy addition and ran the first time. I have NOT tested it very extensively so I would test it heavily but the logic appears solid.
I'm still waiting for my check and this project is no longer interesting but you can now be a hero to your users.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2001 05:05 PM
тАО12-07-2001 05:05 PM
Re: Numbers -> Words for Check Printing
I had been working on the fix but as usual I just managed to clobber your code and got lots of syntax errors. I was writing another subroutine to add the hyphens but you just added it to the same one. Is that better?
P.S. I'm just asking so that I can give you some more points. You really earned these and you have really made me look like a hero. Thanks again to you and to HP for this Forum. It really is the best!!!
Doug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2001 05:12 PM
тАО12-07-2001 05:12 PM
Re: Numbers -> Words for Check Printing
I added the hyphen stuff to the same routine because it uses the @tens and @units arrays. If I had created another subroutine, I would have had to move the arrays out to file scope. I like to keep as much within a subroutine as possible to avoid side effects and unintentional use of variables. It my coding style and I'm sticking to it.
Regards, Clay