Hi there,
I'm pretty new to Revolution.
My question is:
I need to format my output as $9,999,999,999.999999
Is there an easy way to do this?
I looked at the numberFormat thing and the examples aren't
up to snuff. There doesn't appear to be a way for commas
etc. to be used.
Any suggestions?
Thanks in advance!
Rick Harrison
Hi Rick
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!):
function currency rawStr, currSym, beforeAfter, thouSymb, decSym, decPl
-- Parameters:
-- rawstr - unformatted number
-- currSym - currency symbol (can be more than 1 char)
-- beforeAfter - symbol is "before" or "after" the value
-- thouSymb - thousands separator symbol
-- decSym - decimal point symbol
-- decPl - number of decimal places
if not isNumber(decPl) or decPl = 0 then
put round(rawStr) into rawStr
end if
put trunc(rawStr) into wholeNumb
if thouSymb = empty then
put wholeNumb into currStr
else
put empty into currStr
repeat until wholeNumb < 1000
put thouSymb & char -3 to -1 of ("000" & wholeNumb mod 1000) before currStr
put wholeNumb div 1000 into wholeNumb
end repeat
if wholeNumb = 0 then
delete first char of currStr
else
put wholeNumb before currStr
end if
if currStr = empty then put "0" into currStr
end if
if isNumber(decPl) and decPl > 0 then put decSym & round((rawStr - trunc(rawStr)) * (10 ^ decPl)) after currStr
if beforeAfter <> "after" then
put currSym before currStr
else
put currSym after currStr
end if
return currStr
end currency
It is used as follows:
put currency(rawValue, currSymbol, beforeAfter, commaSym, decSym, decPlaces) into ...
e.g.
put currency("12345.34", "Euro", "after", ".", ",", 2)
I hope this helps or at least provides a starting point.
Cheers
Peter
--
Peter Reid
Reid-IT Limited, Loughborough, Leics., UK
Tel: +44 (0)1509 268843 Fax: +44 (0)870 052 7576
E-mail: [EMAIL PROTECTED]
Web: http://www.reidit.co.uk
Reid-IT Limited, Loughborough, Leics., UK
Tel: +44 (0)1509 268843 Fax: +44 (0)870 052 7576
E-mail: [EMAIL PROTECTED]
Web: http://www.reidit.co.uk
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
