<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>Re: Currency Formatting?</title></head><body>
<blockquote type="cite" cite>Hi there,<br>
<br>
I'm pretty new to Revolution.<br>
<br>
My question is:<br>
<br>
I need to format my output as $9,999,999,999.999999<br>
<br>
Is there an easy way to do this?<br>
<br>
I looked at the numberFormat thing and the examples aren't<br>
up to snuff.  There doesn't appear to be a way for commas<br>
etc. to be used.<br>
<br>
Any suggestions?<br>
<br>
Thanks in advance!<br>
</blockquote>
<blockquote type="cite" cite>Rick Harrison</blockquote>
<div><br></div>
<div>Hi Rick</div>
<div><br></div>
<div>The following is a function that produces formatted currency
output.  it was originally developed for MetaCard, but seems to
work OK with Revolution (after quick check!):</div>
<div><br></div>
<blockquote>function currency rawStr, currSym, beforeAfter, thouSymb,
decSym, decPl</blockquote>
<blockquote>  -- Parameters:</blockquote>
<blockquote>  -- rawstr - unformatted number</blockquote>
<blockquote>  -- currSym - currency symbol (can be more than 1
char)</blockquote>
<blockquote>  -- beforeAfter -  symbol is "before"
or "after" the value</blockquote>
<blockquote>  -- thouSymb - thousands separator
symbol</blockquote>
<blockquote>  -- decSym - decimal point symbol</blockquote>
<blockquote>  -- decPl - number of decimal places</blockquote>
<blockquote>  if not isNumber(decPl) or decPl = 0
then</blockquote>
<blockquote>    put round(rawStr) into
rawStr</blockquote>
<blockquote>  end if</blockquote>
<blockquote>  put trunc(rawStr) into wholeNumb</blockquote>
<blockquote>  if thouSymb = empty then</blockquote>
<blockquote>    put wholeNumb into currStr</blockquote>
<blockquote>  else</blockquote>
<blockquote>    put empty into currStr</blockquote>
<blockquote>    repeat until wholeNumb <
1000</blockquote>
<blockquote>      put thouSymb & char -3
to -1 of ("000" & wholeNumb mod 1000) before
currStr</blockquote>
<blockquote>      put wholeNumb div 1000 into
wholeNumb</blockquote>
<blockquote>    end repeat</blockquote>
<blockquote>    if wholeNumb = 0 then</blockquote>
<blockquote>      delete first char of
currStr</blockquote>
<blockquote>    else</blockquote>
<blockquote>      put wholeNumb before
currStr</blockquote>
<blockquote>    end if</blockquote>
<blockquote>    if currStr = empty then put "0"
into currStr</blockquote>
<blockquote>  end if</blockquote>
<blockquote>  if isNumber(decPl) and decPl > 0 then put decSym
& round((rawStr - trunc(rawStr)) * (10 ^ decPl)) after
currStr</blockquote>
<blockquote>  if beforeAfter <> "after"
then</blockquote>
<blockquote>    put currSym before currStr</blockquote>
<blockquote>  else</blockquote>
<blockquote>    put currSym after currStr</blockquote>
<blockquote>  end if</blockquote>
<blockquote>  return currStr</blockquote>
<blockquote>end currency</blockquote>
<div><br></div>
<div>It is used as follows:</div>
<div><br></div>
<blockquote>put currency(rawValue, currSymbol, beforeAfter, commaSym,
decSym, decPlaces) into ...</blockquote>
<div><br></div>
<div>e.g.</div>
<div><br></div>
<blockquote>put currency("12345.34", "Euro",
"after", ".", ",", 2)</blockquote>
<div><br></div>
<div>I hope this helps or at least provides a starting point.</div>
<div><br></div>
<div>Cheers</div>
<div><br></div>
<div>Peter</div>
<x-sigsep><pre>-- 
</pre></x-sigsep>
<div>Peter Reid<br>
Reid-IT Limited, Loughborough, Leics., UK<br>
Tel: +44 (0)1509 268843 Fax: +44 (0)870 052 7576<br>
E-mail: preid@reidit.co.uk<br>
Web: http://www.reidit.co.uk</div>
</body>
</html>