<!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.&nbsp; 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.&nbsp; 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>&nbsp; -- Parameters:</blockquote>
<blockquote>&nbsp; -- rawstr - unformatted number</blockquote>
<blockquote>&nbsp; -- currSym - currency symbol (can be more than 1
char)</blockquote>
<blockquote>&nbsp; -- beforeAfter -&nbsp; symbol is &quot;before&quot;
or &quot;after&quot; the value</blockquote>
<blockquote>&nbsp; -- thouSymb - thousands separator
symbol</blockquote>
<blockquote>&nbsp; -- decSym - decimal point symbol</blockquote>
<blockquote>&nbsp; -- decPl - number of decimal places</blockquote>
<blockquote>&nbsp; if not isNumber(decPl) or decPl = 0
then</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; put round(rawStr) into
rawStr</blockquote>
<blockquote>&nbsp; end if</blockquote>
<blockquote>&nbsp; put trunc(rawStr) into wholeNumb</blockquote>
<blockquote>&nbsp; if thouSymb = empty then</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; put wholeNumb into currStr</blockquote>
<blockquote>&nbsp; else</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; put empty into currStr</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; repeat until wholeNumb &lt;
1000</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; put thouSymb &amp; char -3
to -1 of (&quot;000&quot; &amp; wholeNumb mod 1000) before
currStr</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; put wholeNumb div 1000 into
wholeNumb</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; end repeat</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; if wholeNumb = 0 then</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete first char of
currStr</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; else</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; put wholeNumb before
currStr</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; end if</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; if currStr = empty then put &quot;0&quot;
into currStr</blockquote>
<blockquote>&nbsp; end if</blockquote>
<blockquote>&nbsp; if isNumber(decPl) and decPl &gt; 0 then put decSym
&amp; round((rawStr - trunc(rawStr)) * (10 ^ decPl)) after
currStr</blockquote>
<blockquote>&nbsp; if beforeAfter &lt;&gt; &quot;after&quot;
then</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; put currSym before currStr</blockquote>
<blockquote>&nbsp; else</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; put currSym after currStr</blockquote>
<blockquote>&nbsp; end if</blockquote>
<blockquote>&nbsp; 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(&quot;12345.34&quot;, &quot;Euro&quot;,
&quot;after&quot;, &quot;.&quot;, &quot;,&quot;, 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>