Cheque printing tool

Version 2

     

    Custom Function

     

    Compatibility
    Creator
    Mac OS X, Windows
    Bill Ellemor
    FMP 7, 8, 8.5, 9, 10, 11
    Keywords
    Web: Yes
    File Type: FP7
    Server: Yes
    FileSize: ~ .07 megabytes
    http://

    Description

    This function converts a cheque amount into words for printing cheques directly from a FileMaker database. The main function (fn_ChequeAmount) calls a second function (fn_ChequeWords) which sets the word to be used for each digit, including “zero” or “****” as required.

     


    Code

    PRIMARY FUNCTION—

    /* © 2008 Bill Ellemor, Keywords, Melbourne, Australia

    Custom Function Name: fn_ChequeAmount

    Custom Function Parameters: theAmount

    Custom Function Definition: */

     

    Let ( [

    millions = Int(Mod( theAmount ; 10000000) / 1000000) ;

    hundredthousands = Int(Mod( theAmount ; 1000000) / 100000) ;

    tenthousands = Int(Mod( theAmount ; 100000) / 10000) ;

    thousands = Int(Mod( theAmount ; 10000) / 1000) ;

    hundreds = Int(Mod( theAmount ; 1000) / 100) ;

    tens = Int(Mod( theAmount ; 100) / 10) ;

    units = Int(Mod( theAmount ; 10) / 1) ;

    cents = Round( theAmount - Int( theAmount ); 2) ;

     

    millWord = fn_ChequeWords ( millions ; "" ) ;

    hundthouWord = fn_ChequeWords ( hundredthousands ; millWord ) ;

    tenthouWord = fn_ChequeWords ( tenthousands ; hundthouWord ) ;

    thouWord = fn_ChequeWords ( thousands ; tenthouWord ) ;

    hundWord = fn_ChequeWords ( hundreds ; thouWord ) ;

    tensWord = fn_ChequeWords ( tens ; hundWord ) ;

    unitWord = fn_ChequeWords ( units ; tensWord ) ;

    centWord = If ( cents = 0 ; "00" ; cents * 100 ) ;

     

    tab = "" ;

    space = TextColor ( "|" ; RGB ( 170 ; 0 ; 0 ) ) ;

     

    theWords = tab & millWord & tab & space & tab & hundthouWord & tab & space & tab & tenthouWord & tab & space & tab & thouWord & tab & space & tab & hundWord & tab & space & tab & tensWord & tab & space & tab & unitWord & tab & space & tab & centWord ] ;

     

    theWords )

     

     

    /* This function—

    •it references another custom function, fn_ChequeWords, which defines the text to be used—

    The fn_ChequeWords function converts each digit in a cheque amount into words, as follows: if the digit is 0 and the next higher one is already "****" the result will be "****" ; if the digit is 0 and the next higher one is not "****" the result will be "zero" ; if the digit is not 0 the result will be the value as a word ;

    •converts a specified amount into a single text expression for printing on cheques ;

    •it inserts a vertical coloured separator between each word digit element ;

    •it inserts a tab to position each word and each vertical word separator, allowing the expression to be correctly formatted to suit the final cheque layout */

     

    Sample Input

    Sample Output
    $450.90

    ****|****|****|****|Four|Five|Zero|30

    Developer's Notes

     

    SECONDARY FUNCTION—

    /* © 2008 Bill Ellemor, Keywords, Melbourne, Australia

    Custom Function Name: fn_ChequeWords

    Custom Function Parameters: thisVal, nexthigherVal

    Custom Function Definition: */

     

    Case(

    thisVal = 0 ; If( nexthigherVal = "****" or nexthigherVal = "" ; "****" ; "Zero" ) ;

    thisVal = 1 ; "One" ;

    thisVal = 2 ; "Two" ;

    thisVal = 3 ; "Three" ;

    thisVal = 4 ; "Four" ;

    thisVal = 5 ; "Five" ;

    thisVal = 6 ; "Six" ;

    thisVal = 7 ; "Seven" ;

    thisVal = 8 ; "Eight" ;

    thisVal = 9 ; "Nine" )

     

     

    // NOTE: This function is designed to be called by the primary custom function, fn_ChequeAmount. It converts each digit in a cheque amount into words, as follows: if the digit is 0 and the next higher one is already "****" the result will be "****" ; if the digit is 0 and the next higher one is not "****" the result will be "zero" ; if the digit is not 0 the result will be the value as a word //

     

     


    FileMaker Inc. provides this content on an “As Is” basis, without any warranty, and subject to the terms of the FileMaker Technical Network Agreement. FileMaker makes no representations and is not liable for any content or related information. You may use the content as part of your own solutions and for your customers, but you may not otherwise publicly distribute any content that you did not submit. ©2009-2011 FileMaker, Inc. All Rights Reserved. FileMaker is a trademark of FileMaker, Inc. registered in the U.S. and other countries.