home *** CD-ROM | disk | FTP | other *** search
- *=======================================================================
- * QUICK INTRO
- *
- * Public Domain Clipper utilities. Permission for dist.
- * only if file header descriptions remain.
- * If someone can simplify this please, have at it. Maybe an incremented
- * loop on the case execution??? I am not perfekt.
- * If you do minimize it, please write me about it.
- * I needed this function to get away from the picture @B 999,999,999
- * for printing and screening dollar amounts. Just compile the whole
- * thing for an example..............................................
- *
- *=======================================================================
- ************************************************************************
- *** PROGRAM Program to see DOL_STR work
- ************************************************************************
- CLEAR
- DO WHILE .T.
- CLEAR
- @20,0 SAY "0 Exits"
- STORE 900000000000.00 TO DOLGET
- @3,0 SAY "ENTER THE DOLLAR AMOUNT..."GET DOLGET PICTURE ;
- "999999999999.99"
- READ
- CLEAR
- IF EMPTY(DOLGET)
- EXIT
- ENDIF
- ?
- ?DOL_STR(DOLGET)
- ?
- WAIT
- ENDDO
- *
- *
- *-- EOP FUNC0001
- ************************************************************************
- ************************************************************************
- * FUNCTION LTN Merlin Comp Sys.
- * syntax LTN( <numeric> ) Jeff Morgan
- * returns numeric left trimmed as a string 274 Woodstream Ct.
- * Langhorne, Pa.
- * 19047
- *-----------------------------------------------------------------------
- FUNCTION LTN
- *-----------------------------------------------------------------------
- PARAMETER cl_numb
- RETURN(LTRIM(STR(cl_numb))) && found myself 4ever (L) trimming numerics
- *
- *
- *-- EOF LTN()
- ************************************************************************
- ************************************************************************
- * FUNCTION DOL_STR
- * syntax DOL_STR( < <numeric> )
- * returns numeric left trimmed in dollar format with comma and leading
- * $ sign. additional decimal spaces by adjusting line 67
- *
- * DATE : 4/3/87
- * AUTHOR : MERLIN COMPUTER SYSTEMS
- * Jeff Morgan
- * 274 Woodstream Court
- * Langhorne, Pa. 19047
- *
- * ADDITIONAL - LTN() = left trimmed numeric string
- * ACCURACY - GOOD UP TO 999,999,999,999.99
- *-----------------------------------------------------------------------
- FUNCTION DOL_STR
- *-----------------------------------------------------------------------
- PARAMETERS cl_d_amt
- STORE AT(".",LTN(cl_d_amt)) TO cl_d_len && *** located decimal position
- STORE SUBSTR(LTN(cl_d_amt),1,(cl_d_len-1)) TO cl_d_amt1 && *** substring up to decimal position
- STORE LEN(cl_d_amt1) TO cl_d_len1 && *** length of the substring up to decimal
- STORE SUBSTR(LTN(cl_d_amt),(cl_d_len),3) TO cl_dlrst2 && *** store substring with decimal to end of numeric from decimal position
- STORE LTN(cl_d_amt) TO cl_dlrst1 && *** store for when not fitting in case statments ie < 3
- DO CASE
- CASE cl_d_len1 > 9 .AND. cl_d_len1 < 13 && *** if > 999999999 and < 999999999999
- STORE SUBSTR(cl_d_amt1,1,(cl_d_len1-9)) ; && *** find how much above 999999999 and comma it
- + "," + SUBSTR(cl_d_amt1,((cl_d_len1-9)+1),3) ;
- + "," + SUBSTR(cl_d_amt1,((cl_d_len1-6)+1),3) ;
- + "," + SUBSTR(cl_d_amt1,((cl_d_len1-3)+1),3) ;
- TO cl_dlrst1
- CASE cl_d_len1 > 6 .AND. cl_d_len1 < 10 && *** if > 999999 and < 999999999
- STORE SUBSTR(cl_d_amt1,1,(cl_d_len1-6)) ; && *** find how much above 999999 and comma it
- + "," + SUBSTR(cl_d_amt1,((cl_d_len1-6)+1),3) ;
- + "," + SUBSTR(cl_d_amt1,((cl_d_len1-3)+1),3) ;
- TO cl_dlrst1
- CASE cl_d_len1 > 3 .AND. cl_d_len1 < 7 && if > 999 and < 999999
- STORE SUBSTR(cl_d_amt1,1,(cl_d_len1-3)) ; && *** find how much above 999 and comma it
- + "," + SUBSTR(cl_d_amt1,((cl_d_len1-3)+1),3) ;
- TO cl_dlrst1
- ENDCASE
- DOLRSTRG = "$"+IF(cl_d_len1 < 4,cl_dlrst1,(cl_dlrst1 ; && *** if comma inserted or not and add $
- + cl_dlrst2))
- RETURN(DOLRSTRG) && *** return string dollars with leading $ and commas
- *
- *
- *** EOF DOL_STR()
- ************************************************************************