× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Apparently the attachment was not processed somehow.  Here are the sources:


Service program NbrToWords follows:

      *  =============================================================
      *  =  Service program... NbrToWords                            =
      *  =  Description....... Service program to convert a number   =
      *  =                     to words                              =
      *  =                                                           =
      *  =  CrtRPGMod  Module( YourLib/NbrToWords )       +          =
      *  =             SrcFile( YourLib/YourSrcFile )                =
      *  =                                                           =
      *  =  CrtSrvPgm  SrvPgm( YourLib/NbrToWords )       +          =
      *  =             Export( *All )                     +          =
      *  =             ActGrp( *Caller )                             =
      *  =============================================================

     H NoMain

      *  -------------------------------------------------------------
      *  -  Procedure prototypes                                     -
      *  -------------------------------------------------------------

     D CvtNbrToWords   PR           200
     D                               15  0 Value

      *  -------------------------------------------------------------
      *  -  Global variables                                         -
      *  -------------------------------------------------------------

     D MaxGrps         C                   5

     D Words           S             13    Dim( 99 )
     D                                     CtData

     D Grps            S              8    Dim( MaxGrps )
     D                                     CtData

      *  =============================================================
      *  =  Procedure:   CvtNbrToWords                               =
      *  =  Description: Convert number to words                     =
      *  =============================================================

     P CvtNbrToWords   B                   Export

      *  -------------------------------------------------------------
      *  -  Procedure interface                                      -
      *  -------------------------------------------------------------

     D CvtNbrToWords   PI           200
     D  Nbr                          15  0 Value

      *  -------------------------------------------------------------
      *  -  Variable declarations                                    -
      *  -------------------------------------------------------------

     D AlphaNbr        S             15

     D WorkFld         DS
     D  Work3                         3
     D  Work2                         2    Overlay( Work3 : 2 )
     D  Work1                         1    Overlay( Work3 : 1 )

     D Count           S              5I 0
     D Pos             S              5I 0
     D Idx             S              5I 0

     D RtnWords        S            200    Inz( *Blank )

      *  -------------------------------------------------------------
      *  -  Convert number to words                                  -
      *  -------------------------------------------------------------

     C                   Select

     C                   When      Nbr = *Zero
     C                   Eval      RtnWords = 'zero'

     C                   Other
     C                   If        Nbr < *Zero
     C                   Eval      RtnWords = 'negative'
     C                   Eval      Nbr = Nbr * -1
     C                   EndIf

     C                   Move      Nbr           AlphaNbr

     C                   Do        MaxGrps       Count

     C                   Eval      Pos   = ( Count * 3 ) - 2

     C                   Eval      Work3 = %Subst( AlphaNbr :
     C                                             Pos      :
     C                                             3        )

     C                   If        Work3 <> '000'

     C                   If        Work1 <> '0'
     C                   Clear                   Idx
     C                   Move      Work1         Idx
     C                   Eval      RtnWords = %TrimR( RtnWords )     +
     C                                        ' '                    +
     C                                        %TrimR( Words( Idx ) ) +
     C                                        ' hundred'
     C                   EndIf

     C                   If        Work2 <> '00'
     C                   Clear                   Idx
     C                   Move      Work2         Idx
     C                   Eval      RtnWords = %TrimR( RtnWords )     +
     C                                        ' '                    +
     C                                        %TrimR( Words( Idx ) )
     C                   EndIf

     C                   Eval      RtnWords = %TrimR( RtnWords )    +
     C                                        ' '                   +
     C                                        %TrimR( Grps( Count ) )

     C                   EndIf

     C                   EndDo

     C                   EndSl

     C                   Eval      RtnWords = %Trim( RtnWords )

     C                   Return    RtnWords

     P CvtNbrToWords   E

** CtData Words
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
twenty-one
twenty-two
twenty-three
twenty-four
twenty-five
twenty-six
twenty-seven
twenty-eight
twenty-nine
thirty
thirty-one
thirty-two
thirty-three
thirty-four
thirty-five
thirty-six
thirty-seven
thirty-eight
thirty-nine
forty
forty-one
forty-two
forty-three
forty-four
forty-five
forty-six
forty-seven
forty-eight
forty-nine
fifty
fifty-one
fifty-two
fifty-three
fifty-four
fifty-five
fifty-six
fifty-seven
fifty-eight
fifty-nine
sixty
sixty-one
sixty-two
sixty-three
sixty-four
sixty-five
sixty-six
sixty-seven
sixty-eight
sixty-nine
seventy
seventy-one
seventy-two
seventy-three
seventy-four
seventy-five
seventy-six
seventy-seven
seventy-eight
seventy-nine
eighty
eighty-one
eighty-two
eighty-three
eighty-four
eighty-five
eighty-six
eighty-seven
eighty-eight
eighty-nine
ninety
ninety-one
ninety-two
ninety-three
ninety-four
ninety-five
ninety-six
ninety-seven
ninety-eight
ninety-nine
** CtData Grps
trillion
billion
million
thousand

Here's a sample program, Example, that uses procedure CvtNbrToWords from service
program NbrToWords:

      *  =============================================================
      *  =  Program....... Example                                   =
      *  =  Description... Convert numbers to words example          =
      *  =                                                           =
      *  =  CrtRPGMod  Module( YourLib/Example )          +          =
      *  =             SrcFile( YourLib/YourSrcFile )                =
      *  =                                                           =
      *  =  CrtPgm     Pgm( YourLib/Example )             +          =
      *  =             BndSrvPgm( YourLib/NbrToWords )               =
      *  =============================================================

      *  -------------------------------------------------------------
      *  -  Procedure prototypes                                     -
      *  -------------------------------------------------------------

     D CvtNbrToWords   PR           200
     D                               15  0 Value

      *  -------------------------------------------------------------
      *  -  Variable declarations                                    -
      *  -------------------------------------------------------------

     D MyNbr           S             10I 0
     D MyWords         S            200

      *  -------------------------------------------------------------
      *  -  Sample number-word-conversion                            -
      *  -------------------------------------------------------------

     C                   Eval      MyNbr   = 1234567898
     C                   Eval      MyWords = CvtNbrToWords( MyNbr )
     C                   Eval      *InLR   = *On


Peter Vidal
Programmer Analyst
PALL Aeropower Corp.




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.