Re: 4GL: Decimal type manipulation
Posted in 1998
drance@my-dejanews.com wrote: > > In article <361CEB60.1479@bayer.co.uk>, > Peter.Lancashire.PL1@bayer.co.uk wrote: > > > Why do you want to convert to an integer? Wouldn't a different printout > > of the same decimal value be enough? > > Thanks for the info guys. I got a bit bogged down in the problem - I guess I > should have asked a more open question. WHat I am actually trying to do is > display a decimal as "5.2", for example, if it is not a whole number and to > display "4", for example, if it is. So the display would look like this: > > 4.5 > 6 > 8 > 10 > 5.1 > > I'll try using the info you've given me to do this, but if there is an easier > way... Well, if you only want to format a DEC(3,1), then try something like: ------------------------------------------------------------------------ FUNCTION ..... DEFINE my_val DEC(3,1), my_disp_val CHAR(4) : LET my_disp_val = disp_val(my_val) DISPLAY my_disp_val : : FUNCTION disp_val(the_val) DEFINE the_val CHAR(4) IF the_val[3,4] = ".0" THEN LET the_val = " ", the_val[1,2] END IF RETURN the_val END FUNCTION -- disp_val ------------------------------------------------------------------------ Or something. Just note all the character positions are hard-coded. Hope that helps, -- Mark. +----------------------------------------------------------+-----------+ |Mark D. Stock - Informix SA http://www.informix.com |//////// /| |mailto:mdstock@informix.com http://www.informix.com/idn |///// / //| |http://www.iiug.org +-----------------------------------+//// / ///| | Tel: +27 11 807 0313 |If it's slow, the users complain. |/// / ////| | Fax: +27 11 807 2594 |If it's fast, the users keep quiet.|// / /////| |Cell: +27 83 250 2325 |Therefore, "No news: travels fast"!|/ ////////| +----------------------+-----------------------------------+-----------+