Subject: CHECK WRITING PROGRAM IN INFORMIX
From: Dave Snyder <[email-masked]>
Date: Fri, 19 Nov 1993 22:14:54 -0500 (EST)

In article <[email-masked]> [email-masked] (Sam Jain)
writes:
}
} Does anyone have a readymade check writing program to print checks on
} continuous perforated forms.. in particular, it would need to
} convert like 1296 - to tweleve hundred and ninety six dollars and no cents
} for checks and stuff like that
}

Do you mean like the following... BTW this program is formatted for Deluxe
Computer Check #91002 and has a dol2word() function.

Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip

I N F O   F O R   T A B L E   apchk

Index name          Owner     Type    Cluster  Columns

ixchk_1             dave      unique  No       chk_number

Column name          Type                                    Nulls

chk_number           char(6)                                 no
chk_date             date                                    yes
chk_status           char(1)                                 yes

Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip

I N F O   F O R   T A B L E   apinv

Index name          Owner     Type    Cluster  Columns

ixinv_1             dave      unique  No       ven_code
                                               inv_number
                                               inv_sequence

Column name          Type                                    Nulls

ven_code             char(8)                                 no
inv_number           char(10)                                no
inv_sequence         smallint                                no
inv_date             date                                    yes
inv_amount           money(8,2)                              no
inv_description      char(30)                                yes
batchnum             integer                                 yes
trn_number           integer                                 yes
chk_number           char(6)                                 yes
due_date             date                                    yes

Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip

I N F O   F O R   T A B L E   aptrn

Index name          Owner     Type    Cluster  Columns

ixtrn_1             michele   unique  No       ven_code
                                               inv_number
                                               inv_sequence

ixtrn_2             michele   unique  No       trn_number

Column name          Type                                    Nulls

ven_code             char(8)                                 no
inv_number           char(10)                                no
inv_sequence         smallint                                no
inv_date             date                                    yes
inv_amount           money(8,2)                              no
inv_description      char(30)                                yes
batchnum             integer                                 no
trn_number           serial                                  no
chk_number           char(6)                                 yes
chk_date             date                                    yes

Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip

I N F O   F O R   T A B L E   apven

Index name          Owner     Type    Cluster  Columns

ixven_1             dave      unique  No       ven_code

Column name          Type                                    Nulls

ven_code             char(8)                                 no
ven_name             char(30)                                yes
ven_addr1            char(30)                                yes
ven_addr2            char(30)                                yes
ven_city             char(20)                                yes
ven_state            char(2)                                 yes
ven_zip              char(10)                                yes
ven_phone            char(13)                                yes
ven_contact          char(10)                                yes
ven_ship1            char(30)                                yes
ven_ship2            char(30)                                yes
ven_ship3            char(30)                                yes

Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip
# o_chkp.4gl
# Created by: db4glgen, v3.17 93/11/18 10:22:56

DATABASE accounting

DEFINE  w_record RECORD LIKE aptrn.*             # working record
DEFINE  gv_chk_number LIKE apchk.chk_number

{*******************************************************************************
* This program drives the aptrn screen.
*******************************************************************************}

MAIN
    DEFER INTERRUPT
    CALL menu_aptrn()
END MAIN

{*******************************************************************************
* This function handles the main ring menu.                                    *
*******************************************************************************}

FUNCTION menu_aptrn()
    CALL init_aptrn()

    OPEN FORM o_chkp FROM "o_chkp"
    DISPLAY FORM o_chkp ATTRIBUTE(BLUE)

    CALL qry_aptrn()
    IF NOT int_flag THEN
        CALL out_aptrn()
    END IF

    CLOSE FORM o_chkp
END FUNCTION

{*******************************************************************************
* This function initializes options and variables.                             *
*******************************************************************************}

FUNCTION init_aptrn()
    OPTIONS HELP FILE "o_chkp.msg"
    OPTIONS MESSAGE LINE LAST

    SELECT MAX(chk_number) INTO gv_chk_number FROM apchk
    LET gv_chk_number = gv_chk_number + 1 USING "&&&&"
END FUNCTION

{*******************************************************************************
* This function will query the database table.                                 *
*******************************************************************************}

FUNCTION qry_aptrn()
    DISPLAY "OUTPUT:  ESCAPE outputs.  CTRL-C discards output.  ARROW keys move cursor.", "" AT 1,1 ATTRIBUTE(WHITE)
    DISPLAY "Output select rows in report format.", "" AT 2,1 ATTRIBUTE(WHITE)
    MESSAGE ""

    LET int_flag = FALSE
    INPUT BY NAME gv_chk_number WITHOUT DEFAULTS HELP 2

    RETURN
END FUNCTION

{*******************************************************************************
* This function outputs the current list to the printer.
*******************************************************************************}

FUNCTION out_aptrn()
    DEFINE  w_apinv RECORD LIKE apinv.*
    DEFINE  inv_deduction LIKE apinv.inv_amount

    DECLARE out_curs CURSOR FOR
      SELECT * FROM aptrn ORDER BY ven_code, inv_number, inv_sequence

    START REPORT rpt_aptrn TO PIPE "lp -s -onlq -onoformfeed"
    FOREACH out_curs INTO w_record.*
        LET w_record.chk_date = TODAY
        SELECT inv_date,inv_amount INTO w_apinv.inv_date,w_apinv.inv_amount
          FROM apinv WHERE ven_code = w_record.ven_code
            AND inv_number = w_record.inv_number AND inv_sequence = 1
        SELECT SUM(inv_amount) INTO inv_deduction
          FROM apinv WHERE ven_code = w_record.ven_code
            AND inv_number = w_record.inv_number AND inv_sequence > 1
        IF inv_deduction IS NULL THEN
            LET inv_deduction = 0
        END IF

        OUTPUT TO REPORT rpt_aptrn(w_record.*, w_apinv.*, inv_deduction)
        UPDATE aptrn SET (chk_number, chk_date) = (gv_chk_number, w_record.chk_date)
          WHERE trn_number = w_record.trn_number
    END FOREACH
    FINISH REPORT rpt_aptrn
END FUNCTION

{*******************************************************************************
* This function does the actual formating and printing.                        *
*******************************************************************************}

REPORT rpt_aptrn(w_aptrn, w_apinv, inv_deduction)
DEFINE  w_aptrn RECORD LIKE aptrn.*
DEFINE  w_apinv RECORD LIKE apinv.*
DEFINE  inv_deduction LIKE apinv.inv_amount

    DEFINE  v_record RECORD LIKE apven.*
    DEFINE  sentence CHAR(256)
    DEFINE  i SMALLINT
    DEFINE  details SMALLINT

    OUTPUT
        TOP MARGIN 0
        BOTTOM MARGIN 0
        LEFT MARGIN 0
        PAGE LENGTH 42

    ORDER EXTERNAL BY w_aptrn.ven_code, w_aptrn.inv_number, w_aptrn.inv_sequence

    FORMAT
        PAGE HEADER
            PRINT "XXX"
            PRINT
            LET details = 0

        ON EVERY ROW
            NEED 12 LINES

            PRINT w_apinv.inv_date USING "mm/dd/yy",
              COLUMN 16, w_aptrn.inv_description,
              COLUMN 47, w_apinv.inv_amount USING "#####&.&&",
              COLUMN 59, inv_deduction USING "#####&.&&",
              COLUMN 70, w_aptrn.inv_amount USING "#####&.&&"
            LET details = details + 1

        AFTER GROUP OF w_aptrn.ven_code
            SELECT * INTO v_record.* FROM apven
              WHERE ven_code = w_aptrn.ven_code

            FOR i = 1 TO (13 - details)
                SKIP 1 LINE
            END FOR

            PRINT
            PRINT w_aptrn.chk_date USING "mm/dd/yy",
              COLUMN 13, gv_chk_number,
              COLUMN 46, GROUP SUM(w_apinv.inv_amount) USING "$$$$$$&.&&",
              COLUMN 59, GROUP SUM(inv_deduction) USING "$$$$$$&.&&",
              COLUMN 69, GROUP SUM(w_aptrn.inv_amount) USING "$$$$$$&.&&"
            PRINT
            PRINT "Paid to:  ", v_record.ven_name
            PRINT
            PRINT
            PRINT
            PRINT
            PRINT
            PRINT
            PRINT
            PRINT
            LET sentence = dol2word(GROUP SUM(w_aptrn.inv_amount))
            PRINT COLUMN 5, sentence CLIPPED
            PRINT
            LET sentence = "**$", GROUP SUM(w_aptrn.inv_amount) USING "<<<<<&.&&", "**"
            PRINT COLUMN 41, w_aptrn.chk_date USING "mm/dd/yy",
              COLUMN 54, gv_chk_number,
              COLUMN 64, 14 - LENGTH(sentence CLIPPED) SPACES, sentence CLIPPED
            PRINT
            PRINT
            PRINT COLUMN 10, v_record.ven_name
            PRINT COLUMN 10, v_record.ven_addr1
            IF v_record.ven_addr2 IS NOT NULL THEN
                PRINT COLUMN 10, v_record.ven_addr2
            END IF
            PRINT COLUMN 10, v_record.ven_city CLIPPED,
              ", ",v_record.ven_state, "  ", v_record.ven_zip
            IF v_record.ven_addr2 IS NULL THEN
                PRINT
            END IF
            LET gv_chk_number = gv_chk_number + 1 USING "&&&&"

END REPORT

FUNCTION dol2word(num_dollars)
DEFINE  num_dollars MONEY(8,2)

    DEFINE  str_dollars CHAR(9)
    DEFINE  three_digit_words CHAR(128)
    DEFINE  sentence CHAR(256)

    LET str_dollars = num_dollars USING "&&&&&&.&&"
    INITIALIZE sentence TO NULL

    IF str_dollars[1,3] != "000" THEN
        CALL three_digit_parse(str_dollars[1,3]) RETURNING three_digit_words
        LET sentence = three_digit_words CLIPPED, " THOUSAND"
    END IF

    IF str_dollars[4,6] != "000" THEN
        CALL three_digit_parse(str_dollars[4,6]) RETURNING three_digit_words
        LET sentence = sentence CLIPPED, three_digit_words CLIPPED
    END IF

    IF sentence IS NULL THEN
        LET sentence = " ZERO"
    END IF
    LET sentence = sentence CLIPPED, " AND ", str_dollars[8,9], "/100 DOLLARS"

    IF LENGTH(sentence) > 70 THEN
        LET sentence = num_dollars USING "$<<<,<<&", " AND ", str_dollars[8,9], "/100 DOLLARS"
    END IF

    RETURN sentence
END FUNCTION

FUNCTION three_digit_parse(the_number)
DEFINE  the_number CHAR(3)

    DEFINE  three_digit_words CHAR(128)
    DEFINE  tmp_words CHAR(10)

    INITIALIZE three_digit_words TO NULL

    LET tmp_words = get_hun_nits(the_number, 1)
    IF tmp_words != " ZERO" THEN
        LET three_digit_words = tmp_words CLIPPED, " HUNDRED"
    END IF

    LET tmp_words = get_tens(the_number)
    IF tmp_words != " ZERO" THEN
        LET three_digit_words = three_digit_words CLIPPED, tmp_words CLIPPED
    END IF

    IF the_number[2,2] != "1" THEN
        LET tmp_words = get_hun_nits(the_number, 3)
        IF tmp_words != " ZERO" THEN
            LET three_digit_words = three_digit_words CLIPPED, tmp_words CLIPPED
        END IF
    END IF

    RETURN three_digit_words
END FUNCTION

FUNCTION get_hun_nits(the_number, idx)
DEFINE the_number CHAR(3)
DEFINE idx SMALLINT

    CASE the_number[idx,idx]
        WHEN "0"
            RETURN " ZERO"
        WHEN "1"
            RETURN " ONE"
        WHEN "2"
            RETURN " TWO"
        WHEN "3"
            RETURN " THREE"
        WHEN "4"
            RETURN " FOUR"
        WHEN "5"
            RETURN " FIVE"
        WHEN "6"
            RETURN " SIX"
        WHEN "7"
            RETURN " SEVEN"
        WHEN "8"
            RETURN " EIGHT"
        WHEN "9"
            RETURN " NINE"
    END CASE
END FUNCTION

FUNCTION get_tens(the_number)
DEFINE the_number CHAR(3)

    DEFINE teen_words CHAR(10)

    CASE the_number[2,2]
        WHEN "0"
            RETURN " ZERO"
        WHEN "1"
            CALL get_teens(the_number) RETURNING teen_words
            RETURN teen_words
        WHEN "2"
            RETURN " TWENTY"
        WHEN "3"
            RETURN " THIRTY"
        WHEN "4"
            RETURN " FORTY"
        WHEN "5"
            RETURN " FIFTY"
        WHEN "6"
            RETURN " SIXTY"
        WHEN "7"
            RETURN " SEVENTY"
        WHEN "8"
            RETURN " EIGHTY"
        WHEN "9"
            RETURN " NINETY"
    END CASE
END FUNCTION

FUNCTION get_teens(the_number)
DEFINE the_number CHAR(3)

    CASE
        WHEN the_number[2,3] = "10"
            RETURN " TEN"
        WHEN the_number[2,3] = "11"
            RETURN " ELEVEN"
        WHEN the_number[2,3] = "12"
            RETURN " TWELVE"
        WHEN the_number[2,3] = "13"
            RETURN " THIRTEEN"
        WHEN the_number[2,3] = "14"
            RETURN " FOURTEEN"
        WHEN the_number[2,3] = "15"
            RETURN " FIFTEEN"
        WHEN the_number[2,3] = "16"
            RETURN " SIXTEEN"
        WHEN the_number[2,3] = "17"
            RETURN " SEVENTEEN"
        WHEN the_number[2,3] = "18"
            RETURN " EIGHTEEN"
        WHEN the_number[2,3] = "19"
            RETURN " NINETEEN"
    END CASE
END FUNCTION

Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip

DAS
-- 
David Snyder @ Snide Computer Services - Folcroft, PA         Current Release
                                                              is db4glgen-3.17
UUCP:  ..!uunet!das13!dave   INTERNET:  [email-masked]

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

From: [email-masked] (Dennis Pimple)
Subject: Showing Written $ Amounts
Date: 26 Dec 1995 16:05:16 GMT

Steven Jay Evans ([email-masked]) wrote:
: Any one know how to (Under Informix 4gl) chaanges ie. $24.50 into Twenty F four dollars and 50/100

: E-mail at [email-masked]

This is in the FAQ, but below is my version

=======================================================================
Dennis J. Pimple         [email-masked]    Opinions expressed
Principal Consultant     --------------------    are mine, and do not
Informix Software Inc    Voice:  303-850-0210    necessarily reflect
Denver Colorado USA      Fax:    303-779-4025    those of my employer.
#######     ######   Dennis J. Pimple
##    ##    ##    #  Denver, CO
##    ##    ##    #  ===================================================
##    ## ## ######   Client: Informix User's Group
##    ## ## ## File: %M%  SCCS: %I% %P%
#######  ## ## Date: %G% %U%
         ##    Program: Translate money to a CHAR text,
    #    ##             like for check printing
     #####

#---------------------------------------------------------------------#
MAIN
# Arguments: N/A
# Purpose:   For testing the money input.
#            Just enter an interrupt to quit.
#            REMOVE MAIN TO IMPLEMENT THIS MODULE INTO AN APPLICATION
# Returns:   N/A
#---------------------------------------------------------------------#
DEFINE mny      MONEY
DEFINE mstrg    CHAR(80)

CLEAR SCREEN

WHILE TRUE
    PROMPT "Enter number 0 - 999999.99: " FOR mny
    LET mstrg = fmt_money(mny)
    MESSAGE mstrg CLIPPED
END WHILE

END MAIN

#---------------------------------------------------------------------#
FUNCTION fmt_money(mny)
# Arguments: Amount of money to format
# Purpose:   Format money amount into a character string
# Returns:   CHAR(80) with the money string
# Usage:     LET charvar = fmt_money(moneyvar)
#    or:     CALL fmt_money(moneyvar) RETURNING charvar
# The return can change according to the maximum amount of the money
# Hundreds of thousands (777,777.00) requires char(77)
# Tens of thousands (77,777.00) requires char(61)
# Thousands (7,777.00) requires char(53)
# Hundreds (777.00) requires char(38)
# if you never write a check in the hundreds,
# you don't need this program
# change the LET mlgth statement below to reflect any change you make
# to rstrg
#---------------------------------------------------------------------#
DEFINE mny      MONEY       # amount passed
DEFINE mstrg    CHAR(9)     # mny amount in a string
DEFINE nstrg    CHAR(3)     # hundreds digitaly (eg: "090")
DEFINE hstrg    CHAR(30)    # hundreds in char format
DEFINE lgth     SMALLINT    # length measurment
DEFINE rstrg    CHAR(80)    # Return string;CHANGE THIS LENGTH AS REQ
DEFINE mlgth    SMALLINT    # length of mstrg

# set mlgth to the max length of rstrg
LET mlgth = 80

IF mny IS NULL THEN
    LET mny = 0
END IF

LET mstrg = mny USING "<<<<<<.&&"

LET rstrg = ""
LET lgth = LENGTH(mstrg)
IF lgth > 6 THEN
    # this number is in the thousands
    # caculate how many thousands and reduce the mstrg to hundreds
    CASE
    WHEN lgth = 9
        # hundreds of thousands
        LET nstrg = mstrg[1,3]
        LET mstrg = mstrg[4,9]
    WHEN lgth = 8
        # tens of thousands
        LET nstrg = mstrg[1,2]
        LET mstrg = mstrg[3,8]
    WHEN lgth = 7
        # single thousands
        LET nstrg = mstrg[1]
        LET mstrg = mstrg[2,7]
    END CASE
    # nstrg now holds a number between 1 and 999
    LET hstrg = fmt_hund(nstrg)
    LET rstrg = rstrg CLIPPED, " ", hstrg CLIPPED, " THOUSAND"
END IF

LET lgth = LENGTH(mstrg)
IF lgth > 3 THEN
    # this number is in the hundreds
    CASE
    WHEN lgth = 6
        # hundreds
        LET nstrg = mstrg[1,3]
        LET mstrg = mstrg[4,6]
    WHEN lgth = 5
        # tens
        LET nstrg = mstrg[1,2]
        LET mstrg = mstrg[3,5]
    WHEN lgth = 4
        # single digits
        LET nstrg = mstrg[1]
        LET mstrg = mstrg[2,4]
    END CASE
    # nstrg now holds a number between 1 and 999
    LET hstrg = fmt_hund(nstrg)
    # add it to the (possible) thousands
    LET rstrg = rstrg CLIPPED, " ", hstrg CLIPPED
END IF

IF LENGTH(rstrg) = 0 THEN
    # if we still have nothing, there was no dollars
    LET rstrg = " ZERO"
END IF
# put the cents on as a fraction of hundreds
LET rstrg = rstrg CLIPPED, " AND ", mstrg[2,3], "/100"

# fill the left of the string with ***
# REMOVE THE NEXT THREE LINES IF YOU DON'T WANT THIS DONE
WHILE LENGTH(rstrg) < mlgth
    LET rstrg = "*", rstrg CLIPPED
END WHILE

RETURN rstrg

END FUNCTION
# fmt_money(mny)

#---------------------------------------------------------------------#
FUNCTION fmt_hund(nstrg)
# Arguments: CHAR(3) string 000 - 999 with the possible hundreds
# Purpose:   Format hundreds amount into a character string
# Returns:   CHAR(30) with the hundreds format
#---------------------------------------------------------------------#
DEFINE nstrg    CHAR(3)     # "000" - "999"
DEFINE n1       CHAR(1)     # single digits tester
DEFINE n2       CHAR(2)     # double digits tester
DEFINE lgth     SMALLINT    # length measurement
DEFINE hstrg    CHAR(30)    # hundreds string to return
DEFINE tstrg    CHAR(13)    # tens string to get from fmt_tens
DEFINE x        SMALLINT    # a little counter

LET lgth = LENGTH(nstrg)
# since nstrg might be 000 or 010 or something like that,
# we need to remove any leading zeros
FOR x = 1 TO lgth
    IF nstrg[1] = "0" THEN
        LET nstrg = nstrg[2,lgth]
    ELSE
        EXIT FOR
    END IF
END FOR

LET lgth = LENGTH(nstrg)
CASE
WHEN lgth = 3
    # hundreds
    LET n1 = nstrg[1]
    LET hstrg = fmt_digit(n1)
    LET hstrg = hstrg CLIPPED, " HUNDRED"
    LET n2 = nstrg[2,3]
    # get the tens part of this number
    LET tstrg = fmt_tens(n2)
    LET hstrg = hstrg CLIPPED, " ", tstrg CLIPPED
WHEN lgth = 2
    # tens
    LET n2 = nstrg CLIPPED
    LET hstrg = fmt_tens(n2)
WHEN lgth = 1
    LET n1 = nstrg CLIPPED
    LET hstrg = fmt_digit(n1)
END CASE

RETURN hstrg

END FUNCTION
# fmt_hund(nstrg)

#---------------------------------------------------------------------#
FUNCTION fmt_tens(n)
# Arguments: CHAR(2) string 00 - 99 with the possible tens
# Purpose:   Format tens amount into a character string
# Returns:   CHAR(30) with the tens format
#---------------------------------------------------------------------#
DEFINE n     CHAR(2)
DEFINE tstrg CHAR(30)

CASE
WHEN n = "10"
    LET tstrg = "TEN"
WHEN n = "11"
    LET tstrg = "ELEVEN"
WHEN n = "12"
    LET tstrg = "TWELVE"
WHEN n = "13"
    LET tstrg = "THIRTEEN"
WHEN n = "14"
    LET tstrg = "FOURTEEN"
WHEN n = "15"
    LET tstrg = "FIFTEEN"
WHEN n = "16"
    LET tstrg = "SIXTEEN"
WHEN n = "17"
    LET tstrg = "SEVENTEEN"
WHEN n = "18"
    LET tstrg = "EIGHTEEN"
WHEN n = "19"
    LET tstrg = "NINETEEN"
OTHERWISE
    # we can get the singles digit from fmt_digit
    LET tstrg = fmt_digit(n[2])
    CASE
    WHEN n[1] = "2"
        LET tstrg = "TWENTY ", tstrg CLIPPED
    WHEN n[1] = "3"
        LET tstrg = "THIRTY ", tstrg CLIPPED
    WHEN n[1] = "4"
        LET tstrg = "FORTY ", tstrg CLIPPED
    WHEN n[1] = "5"
        LET tstrg = "FIFTY ", tstrg CLIPPED
    WHEN n[1] = "6"
        LET tstrg = "SIXTY ", tstrg CLIPPED
    WHEN n[1] = "7"
        LET tstrg = "SEVENTY ", tstrg CLIPPED
    WHEN n[1] = "8"
        LET tstrg = "EIGHTY ", tstrg CLIPPED
    WHEN n[1] = "9"
        LET tstrg = "NINETY ", tstrg CLIPPED
    END CASE
END CASE

RETURN tstrg

END FUNCTION
# fmt_tens(n)

#---------------------------------------------------------------------#
FUNCTION fmt_digit(n)
# Arguments: CHAR(1) string 0 - 9 with the possible digits
# Purpose:   Format digits amount into a character string
# Returns:   CHAR(5) with the digits format
#---------------------------------------------------------------------#
DEFINE n CHAR(1)

CASE
WHEN n = "0"
    RETURN ""
WHEN n = "1"
    RETURN "ONE"
WHEN n = "2"
    RETURN "TWO"
WHEN n = "3"
    RETURN "THREE"
WHEN n = "4"
    RETURN "FOUR"
WHEN n = "5"
    RETURN "FIVE"
WHEN n = "6"
    RETURN "SIX"
WHEN n = "7"
    RETURN "SEVEN"
WHEN n = "8"
     RETURN "EIGHT"
WHEN n = "9"
    RETURN "NINE"
END CASE

END FUNCTION
# fmt_digit(n)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

From: [email-masked] (Ahmad Pakhri Yahya / Aseam6)
Subject: Re: Showing Written $ Amounts
Date: 31 Dec 1995 23:08:04 -0500

Steven Jay Evans ([email-masked]) wrote:
: Any one know how to (Under Informix 4gl) chaanges ie. $24.50 into
Twenty F four dollars and 50/100

: E-mail at [email-masked]

Below is my way of doing it, I think may be you need to modify a bit.
# Function testword() below is just a temporary function to test
# the numtowrd(numvar) function in converting the number into word. To
# use the numtowrd(numvar) function, just call from anywhere in in the
# program. This function receive a decimal(20,2) data type and return
# a char(250) data type.  If the original number is not decimal(20,2),
# it can be converted to this data type easily.

FUNCTION testword()
   define num decimal(20,2),
      dnum char(27),
      wrd char(250),
      x char(1)
   open window w_pwrd at 6,30
      with 1 rows, 18 columns
      attribute (border)
   whenever error continue
   error "PLEASE ENTER NUMBERS ONLY"
   prompt "" for num
   let wrd = numtowrd(num)
   close window w_pwrd
   let formname = formpath, "dnumwrd"
   open window w_dwrd at 9,2
      with form formname
   display wrd to wrd
   let dnum = num using "$$$$,$$$,$$$,$$$,$$$,$$$.&&"
   display dnum to dnum
   prompt "" for char x
   close window w_dwrd
END FUNCTION

FUNCTION numtowrd(numvar)
   define aa, bb, cc, dd, ee, ff, gg smallint,
      numvar decimal(20,2),
      numalp char(21),
      numcha char(3),
      numwrd1, numwrd2 char(250)
   call repo_id("numtowrd","fnc_fl5")
   let numwrd1 = ""
   let numalp = numvar
   let aa = length(numalp)
   let bb = aa mod 3
   let cc = aa / 3
   for dd = 1 to cc
      let ee = aa - ((dd - 1) * 3)
      let ff = ee - 2
      let numcha = numalp[ff,ee]
      let numwrd1 = cnv(dd,numcha)
      let numwrd2 = numwrd1 clipped, numwrd2 clipped
   end for
   if bb <> 0 then
      let numcha = numalp[1,bb]
      case bb
         when 1 let numcha = "00", numcha clipped
         when 2 let numcha = "0", numcha clipped
      end case
      let numwrd1 = cnv(dd,numcha)
      let numwrd2 = numwrd1 clipped, numwrd2 clipped
   end if
   let numwrd2 = "Ringgit Malaysia :", numwrd2 clipped, " Only"
   return(numwrd2)
END FUNCTION

FUNCTION cnv(no1,ch1)
   define no1 smallint,
      ch1 char(3),
      sch char(1),
      dch char(2),
      wrd char(50)
   if ch1 = "000" or ch1 = ".00" then
      if no1 = 1 and ch1 = ".00" then
         let wrd = ""
         return(wrd)
      else
         let wrd = ""
         return(wrd)
      end if
   end if
   let sch = ch1[1]
   case ch1[1]
      when "0"   let wrd = ""
      when ""    let wrd = ""
      when "."   let wrd = " and sen"
      otherwise  let wrd = cnv1(sch) clipped, " Hundred"
   end case
   let dch = ch1[2,3]
   case ch1[2]
      when ""    let wrd = wrd clipped, ""
      when "1"   let wrd = wrd clipped, cnv2(dch) clipped
      otherwise  let wrd = wrd clipped, cnv3(dch) clipped
   end case
   case no1
      when 1     let wrd = wrd clipped, ""
      when 2     let wrd = wrd clipped, ""
      when 3     let wrd = wrd clipped, " Thousand"
      when 4     let wrd = wrd clipped, " Million"
      when 5     let wrd = wrd clipped, " Billion"
      when 6     let wrd = wrd clipped, " Trillion"
      when 7     let wrd = wrd clipped, " Zillion"
   end case
   return(wrd)
END FUNCTION

FUNCTION cnv1(num1)
   define num1 char(1),
      wrd1 char(30)
   case num1
      when "1"   let wrd1 = " One"
      when "2"   let wrd1 = " Two"
      when "3"   let wrd1 = " Three"
      when "4"   let wrd1 = " Four"
      when "5"   let wrd1 = " Five"
      when "6"   let wrd1 = " Six"
      when "7"   let wrd1 = " Seven"
      when "8"   let wrd1 = " Eight"
      when "9"   let wrd1 = " Nine"
   end case
   return(wrd1)
END FUNCTION

FUNCTION cnv2(num1)
   define num1 char(2),
      wrd1 char(30)
   case num1[2]
      when "0"   let wrd1 = " Ten"
      when "1"   let wrd1 = " Eleven"
      when "2"   let wrd1 = " Twelve"
      when "3"   let wrd1 = " Thirteen"
      when "4"   let wrd1 = " Fourteen"
      when "5"   let wrd1 = " Fifteen"
      when "6"   let wrd1 = " Sixteen"
      when "7"   let wrd1 = " Seventeen"
      when "8"   let wrd1 = " Eighteen"
      when "9"   let wrd1 = " Nineteen"
   end case
   return(wrd1)
END FUNCTION

FUNCTION cnv3(num1)
   define num1 char(2),
      num2 char(1),
      wrd1 char(30)
   case num1[1]
      when "0"   let wrd1 = ""
      when "2"   let wrd1 = " Twenty"
      when "3"   let wrd1 = " Thirty"
      when "4"   let wrd1 = " Forty"
      when "5"   let wrd1 = " Fifty"
      when "6"   let wrd1 = " Sixty"
      when "7"   let wrd1 = " Seventy"
      when "8"   let wrd1 = " Eighty"
      when "9"   let wrd1 = " Ninety"
   end case
   let num2 = num1[2]
   let wrd1 = wrd1 clipped, cnv1(num2) clipped
   return(wrd1)
END FUNCTION

  ---------------
      ///I\\\    Ahmad Pakhri Yahya ([email-masked])
     // o o \\   Supervisor, Admin, Root, DBA
     //  v  \\   ----------------------------------------------------
     //  -  \\   ISD, Aseambankers Malaysia Berhad
    ///     \\\  Kuala Lumpur, Malaysia.
  ---------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

From: [email-masked] (June Tong)
Subject: Re: Displaying money values as words (check writing)
Date: 3 Jul 1996 18:09:18 GMT

mhodges ([email-masked]) wrote:
: I need to write out money variables to a report as words instead of
: numbers to print checks (i.e. ONE THOUSAND TWO HUNDRED THIRTY AND NO CENTS).

4GL?  I put some 4GL code in our TechInfo database (may be accessible via
I-Link but I'm not sure) that does that.  I didn't write it myself, and I
don't remember whether I even tested it before I put it there, so if you have
any problems with it, you didn't get it from me ;-)  I've attached it below,
in case you don't have access to I-Link or it's not there.  BTW, I-Link does
contain a lot of useful (and useless) stuff like this.  (Oh boy, I'm starting
to sound like Clem, plugging our other services ;-)

June

----   June Tong                              Informix Software    ----
----   Senior Consultant                      (415) 926-6140       ----
----   International Support                  [email-masked]   ----
----       Location-du-jour: Miami                                 ----
*
* Standard disclaimers apply
*
- Please do not send me requests/questions by mail.  When I have the knowledge
- and time permits, I try to answer questions on comp.databases.informix, but
- travel schedule, time, and volume make responding to personal requests
- difficult and often slow.  Please call your local Informix Technical Support
- organization for assistance with technical issues.

----------------------------  TI #4160  ----------------------------

Title:   Print English Text for American Money Values (for checks)
Sub. Date:    04/15/1993

This 4GL program produces the American-English representation of a money value
(in American Dollars).

Short Desc:
     Would like to have character representation of money for checks

Long Desc:
     It would be nice to have a function to print the  character string of a
     money field, as is done on checks.
     $250.00 would be printed Two Hundred and Fifty  Dollars and No Cents.

----------------------------  Cut Here  ----------------------------

globals
    define tens array[10] of varchar(20)
    define ones array[20] of varchar(20)
    define units array[22] of varchar(20)
end globals

main
    call init_names()
    call number(0)
    call number(12)
    call number(1234)
    call number(1234.78)
    call number(1234567890.12)
    call number(1000)
    call number(2000000)
    call number(3000000000.0)
    call number(40000000000000.0)
    call number(5000000000000000.0)
    call number(6000000000000000000.0)
    call number(7000000000000000000000.0)
    call number(8000000000000000000000000.0)
    call number(1.23456789e27)
    call number(1.23456789e28)
    call number(1.23456789e29)
end main

function number(m)
    define m money(32,2),
    result varchar(255)

    call mtoa(m, 0) returning result
    display m, " = ", result
end function

function init_names()
    let ones[1] = "One"
    let ones[2] = "Two"
    let ones[3] = "Three"
    let ones[4] = "Four"
    let ones[5] = "Five"
    let ones[6] = "Six"
    let ones[7] = "Seven"
    let ones[8] = "Eight"
    let ones[9] = "Nine"
    let ones[10] = "Ten"
    let ones[11] = "Eleven"
    let ones[12] = "Twelve"
    let ones[13] = "Thirteen"
    let ones[14] = "Fourteen"
    let ones[15] = "Fifteen"
    let ones[16] = "Sixteen"
    let ones[17] = "Seventeen"
    let ones[18] = "Eighteen"
    let ones[19] = "Nineteen"

    let tens[1] = "Ten"
    let tens[2] = "Twenty"
    let tens[3] = "Thirty"
    let tens[4] = "Forty"
    let tens[5] = "Fifty"
    let tens[6] = "Sixty"
    let tens[7] = "Seventy"
    let tens[8] = "Eighty"
    let tens[9] = "Ninety"

    let units[1] = "Thousand"
    let units[2] = "Million"
    let units[3] = "Billion"
    let units[4] = "Trillion"
    let units[5] = "Quadrillion"
    let units[6] = "Quintillion"
    let units[7] = "Sextillion"
    let units[8] = "Septillion"
    let units[9] = "Octillion"
    let units[10] = "Nonillion"
    let units[11] = "Decillion"
    let units[12] = "Undecillion"
    let units[13] = "Duodecillion"
    let units[14] = "Tredecillion"
    let units[15] = "Quattuordecillion"
    let units[16] = "Quindecillion"
    let units[17] = "Sexdecillion"
    let units[18] = "Septendecillion"
    let units[19] = "Octodecillion"
    let units[20] = "Novemdecillion"
    let units[21] = "Vigintillion"
end function

function mtoa(m, level)
    define m decimal(32,2),
	old decimal(32,2),
	level int,
	x, y, z int,
	string varchar(255),
	temp char(40)

    if (m < 1 and level > 0) then
	return ""
    end if

    let old = m

    call take_digit(m) returning m, z
    call take_digit(m) returning m, y
    call take_digit(m) returning m, x

    let string = ""
    if (x > 0  and x < 10) then
        let string = concat(ones[x], "Hundred")
    end if

    if (y) then
	if (y == 1) then
	    let string = concat(string, ones[y*10 + z])
	    let z = 0
	else
	    let string = concat(string, tens[y])
	end if
    end if

    if (z) then
        let string = concat(string, ones[z])
    end if

    if (level >= 1 and string is not null) then
	let string = concat(string, units[level])
    end if

    if (level == 0) then
        if (m == 0 and string is null) then
	    let string = "Zero"
	end if
	let temp = old
	let x = length(temp)
	let temp = temp[x - 1, x]
	let string = concat(string, "and")
	let string = string, " ", temp clipped, "/100 Dollars"
    end if

    let string = concat(mtoa(m, level + 1),  string)
    return string
end function

function take_digit(m)
    define m decimal(32, 2),
	x varchar(50),
	i int

    let x = m
    let m = m / 10
    let i = length(x)
    return m, x[i-3]
end function

function concat(a, b)
    define a, b, c varchar(200)
    if (a) then
        let c = a clipped, " ", b
        return c
    else
	return b
    end if
end function

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++