From: SkippyPB on
On Sun, 8 Aug 2010 02:20:57 -0700 (PDT), "sharad kumar.j"
<aryansmit3754(a)gmail.com> wrote:

>hi,
>I hhave started my programming in cobol and i'm 3 weeks old.I would
>like to know that is there any built in function to convert amount in
>number to words
>eg:345
>as
>three hundred and forty five....

WoW! I'm impressed...3 weeks old and not only using a computer but
typing on it as well! That's some gene pool you came from.

To answer your question, in IBM Mainframe's latest version - no.

Regards,
--

////
(o o)
-oOO--(_)--OOo-



"If I held you any closer I would be on the
other side of you."
-- Groucho Marx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Remove nospam to email me.

Steve
From: SkippyPB on
On Mon, 9 Aug 2010 01:04:03 +1200, "Pete Dashwood"
<dashwood(a)removethis.enternet.co.nz> wrote:

>sharad kumar.j wrote:
>> hi,
>> I hhave started my programming in cobol and i'm 3 weeks old.I would
>> like to know that is there any built in function to convert amount in
>> number to words
>> eg:345
>> as
>> three hundred and forty five....
>
>This post brought back some memories for me.
>
>As a young COBOL programmer myself once, I remember being asked to provide a
>subroutine that would do exactly what you ask. It was to be used for
>printing the amount in words on cheques. It seemed pretty straightforward:
>Use a table lookup to convert the words into numbers and the mighty COBOL
>STRING verb to put the words together. How hard could it be?
>
>Doc Dwarf has frequently reminded us here of the dangers inherent in the
>phrase: "All y' gotta do..." He is absolutely right.
>
>I found to my consternation that the words AND, DOLLARS, CENTS and ONLY also
>needed to be added to the string, and they also wanted the word 'EXACTLY' if
>there were zero cents in the amount.
>
>Some examples:
>
>one thousand three hundred and twenty seven dollars and nine cents only.
>(1327.09)
>one thousand three hundred and twenty seven dollars exactly (1327.00)
>one hundred and one thousand three hundred and twenty seven dollars and nine
>cents only. (101327.09)
>
>The placement of DOLLARS, CENTS, ONLY, and EXACTLY is fairly simple, but
>the placement of AND became problematic and the rules for when it was needed
>were not entirely clear. Attempting to retrofit to the code I had hastily
>written resulted in some pretty awful spaghetti...
>
>Finally, I decided to sit down and work out all the cases where AND must be
>added to the string.
>
>1. preceding the cents UNLESS there were no digits to the left of the point,
>OR the cents were zero.
>1. Between hundreds and tens. (three hundred and twenty five).
>2. Between thousands and tens IF there are NO hundreds. (one thousand AND
>twenty seven...)
>3. Between hundreds of thousands and tens of thousands. (three hundred AND
>twenty five thousand, four hundred AND tweny-nine...)
>
>Writing this as a bunch of COBOL IFs was not pretty so I applied Boolean
>simplification and came up with a single compound condition which did it.
>(In effect it decided if the next word to be added to the string should be a
>number or the word AND...)
>
>I was so proud of this I showed it to the head programmer who checked it in
>his head and pronounced it OK. (he was a disabled guy with a mind like a
>razor and I learned much from him. He was the guy who first interested me in
>propositional calculus and Boolean algebra.)
>
>I then rewrote the code from scratch as a callable subroutine, which
>received a number and returned a string, and remembered the experience right
>to this day, some 42 years later... :-)
>
>If I had the code, I would gladly give it to you, but I think you will have
>the same fun and sense of achievement I got, if you do it yourself.
>
>Havea shot at it and, if you get stuck, post your attempt here.
>
>Pete.

I have an IBM Assembler routine that does this in English and Thai!
Probably half the size of a Cobol version. Not for sale, though.

Regards,
--

////
(o o)
-oOO--(_)--OOo-



"If I held you any closer I would be on the
other side of you."
-- Groucho Marx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Remove nospam to email me.

Steve
From: Anonymous on
In article <64148df3-a7a7-47c5-882d-8c9a53fe63e6(a)a4g2000prm.googlegroups.com>,
sharad kumar.j <aryansmit3754(a)gmail.com> wrote:
>hi,
>I hhave started my programming in cobol and i'm 3 weeks old.I would
>like to know that is there any built in function to convert amount in
>number to words
>eg:345
>as
>three hundred and forty five....

To the best of my knowledge there is no such built-in function in any
dialect of COBOL which does this.

To the best of my experience there is no instructor worth a paycheck who
would assign such a thing to a three-week class.

Please do your own homework.

DD

From: Alistair on
On Aug 8, 5:12 pm, SkippyPB <swieg...(a)Nospam.neo.rr.com> wrote:
> On Mon, 9 Aug 2010 01:04:03 +1200, "Pete Dashwood"
>
>
>
>
>
> <dashw...(a)removethis.enternet.co.nz> wrote:
> >sharad kumar.j wrote:
> >> hi,
> >> I hhave started my programming in cobol and i'm 3 weeks old.I would
> >> like to know that is there any built in function to convert amount in
> >> number to words
> >> eg:345
> >> as
> >> three hundred and forty five....
>
> >This post brought back some memories for me.
>
> >As a young COBOL programmer myself once, I remember being asked to provide a
> >subroutine that would do exactly what you ask. It was to be used for
> >printing the amount in words on cheques. It seemed pretty straightforward:
> >Use a table lookup to convert the words into numbers and the mighty COBOL
> >STRING verb to put the words together. How hard could it be?
>
> >Doc Dwarf has frequently reminded us here of the dangers inherent in the
> >phrase: "All y' gotta do..." He is absolutely right.
>
> >I found to my consternation that the words AND, DOLLARS, CENTS and ONLY also
> >needed to be added to the string, and they also wanted the word 'EXACTLY' if
> >there were zero cents in the amount.
>
> >Some examples:
>
> >one thousand three hundred and twenty seven dollars and nine cents only.
> >(1327.09)
> >one thousand three hundred and twenty seven dollars exactly (1327.00)
> >one hundred and one thousand three hundred and twenty seven dollars and nine
> >cents only. (101327.09)
>
> >The placement of DOLLARS,  CENTS, ONLY, and EXACTLY is fairly simple, but
> >the placement of AND became problematic and the rules for when it was needed
> >were not entirely clear. Attempting to retrofit to the code I had hastily
> >written resulted in some pretty awful spaghetti...
>
> >Finally, I decided to sit down and work out all the cases where AND must be
> >added to the string.
>
> >1. preceding the cents UNLESS there were no digits to the left of the point,
> >OR the cents were zero.
> >1. Between hundreds and tens. (three hundred and twenty five).
> >2. Between thousands and tens IF there are NO hundreds. (one thousand AND
> >twenty seven...)
> >3. Between hundreds of thousands and tens of thousands. (three hundred AND
> >twenty five thousand, four hundred AND tweny-nine...)
>
> >Writing this as a bunch of COBOL IFs was not pretty so I applied Boolean
> >simplification and came up with a single compound condition which did it..
> >(In effect it decided if the next word to be added to the string should be a
> >number or the word AND...)
>
> >I was so proud of this I showed it to the head programmer  who checked it in
> >his head and pronounced it OK. (he was a disabled guy with a mind like a
> >razor and I learned much from him. He was the guy who first interested me in
> >propositional calculus and Boolean algebra.)
>
> >I then rewrote the code from scratch as a callable subroutine, which
> >received a number and returned a string, and remembered the experience right
> >to this day, some 42 years later... :-)
>
> >If I had the code, I would gladly give it to you, but I think you will have
> >the same fun and sense of achievement I got, if you do it yourself.
>
> >Havea shot at it and, if you get stuck, post your attempt here.
>
> >Pete.
>
> I have an IBM Assembler routine that does this in English and Thai!
> Probably half the size of a Cobol version.  Not for sale, though.

I presume romanized Thai? as IIRC Thai is all squiggly characters.
From: SkippyPB on
On Mon, 9 Aug 2010 03:32:01 -0700 (PDT), Alistair
<alistair(a)ld50macca.demon.co.uk> wrote:

>On Aug 8, 5:12�pm, SkippyPB <swieg...(a)Nospam.neo.rr.com> wrote:
>> On Mon, 9 Aug 2010 01:04:03 +1200, "Pete Dashwood"
>>
>>
>>
>>
>>
>> <dashw...(a)removethis.enternet.co.nz> wrote:
>> >sharad kumar.j wrote:
>> >> hi,
>> >> I hhave started my programming in cobol and i'm 3 weeks old.I would
>> >> like to know that is there any built in function to convert amount in
>> >> number to words
>> >> eg:345
>> >> as
>> >> three hundred and forty five....
>>
>> >This post brought back some memories for me.
>>
>> >As a young COBOL programmer myself once, I remember being asked to provide a
>> >subroutine that would do exactly what you ask. It was to be used for
>> >printing the amount in words on cheques. It seemed pretty straightforward:
>> >Use a table lookup to convert the words into numbers and the mighty COBOL
>> >STRING verb to put the words together. How hard could it be?
>>
>> >Doc Dwarf has frequently reminded us here of the dangers inherent in the
>> >phrase: "All y' gotta do..." He is absolutely right.
>>
>> >I found to my consternation that the words AND, DOLLARS, CENTS and ONLY also
>> >needed to be added to the string, and they also wanted the word 'EXACTLY' if
>> >there were zero cents in the amount.
>>
>> >Some examples:
>>
>> >one thousand three hundred and twenty seven dollars and nine cents only.
>> >(1327.09)
>> >one thousand three hundred and twenty seven dollars exactly (1327.00)
>> >one hundred and one thousand three hundred and twenty seven dollars and nine
>> >cents only. (101327.09)
>>
>> >The placement of DOLLARS, �CENTS, ONLY, and EXACTLY is fairly simple, but
>> >the placement of AND became problematic and the rules for when it was needed
>> >were not entirely clear. Attempting to retrofit to the code I had hastily
>> >written resulted in some pretty awful spaghetti...
>>
>> >Finally, I decided to sit down and work out all the cases where AND must be
>> >added to the string.
>>
>> >1. preceding the cents UNLESS there were no digits to the left of the point,
>> >OR the cents were zero.
>> >1. Between hundreds and tens. (three hundred and twenty five).
>> >2. Between thousands and tens IF there are NO hundreds. (one thousand AND
>> >twenty seven...)
>> >3. Between hundreds of thousands and tens of thousands. (three hundred AND
>> >twenty five thousand, four hundred AND tweny-nine...)
>>
>> >Writing this as a bunch of COBOL IFs was not pretty so I applied Boolean
>> >simplification and came up with a single compound condition which did it.
>> >(In effect it decided if the next word to be added to the string should be a
>> >number or the word AND...)
>>
>> >I was so proud of this I showed it to the head programmer �who checked it in
>> >his head and pronounced it OK. (he was a disabled guy with a mind like a
>> >razor and I learned much from him. He was the guy who first interested me in
>> >propositional calculus and Boolean algebra.)
>>
>> >I then rewrote the code from scratch as a callable subroutine, which
>> >received a number and returned a string, and remembered the experience right
>> >to this day, some 42 years later... :-)
>>
>> >If I had the code, I would gladly give it to you, but I think you will have
>> >the same fun and sense of achievement I got, if you do it yourself.
>>
>> >Havea shot at it and, if you get stuck, post your attempt here.
>>
>> >Pete.
>>
>> I have an IBM Assembler routine that does this in English and Thai!
>> Probably half the size of a Cobol version. �Not for sale, though.
>
>I presume romanized Thai? as IIRC Thai is all squiggly characters.

No, I wrote it when I was in Thailand and thus had access to their
code page on the mainframe. They have an EBCIDIC code for all of
their little squigglies as you call them and there are more than 44
characters in the Thai alphabet. The IBM code page also supports the
26 English letter in the alphabet. They made use of mostly unused
EBCDIC codes like B1, B2 etc. So, with the help of a native Thai
speaker, it wasn't too difficult to write a number to Thai program.
Still used to this day at at least two client sites to print the
amount on checks as far as I know.

Regards,
--

////
(o o)
-oOO--(_)--OOo-



"Ice Water? Get some Onions - that'll make your
eyes water!"
-- Groucho Marx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Remove nospam to email me.

Steve
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7
Prev: New to COBOL
Next: RosettaCode