Hello Marty,

I use the following. It could use a little editing, but it works with positive and negative real numbers.

        Gregory

function commaFormat x
  if x is not a number
  then
    return "Error: not a number"
    exit commaFormat
  else
    put trunc(abs(x)) into truncAbsX
    repeat until length(truncAbsX) mod 3 = 0
      put "d" before truncAbsX
      add 1 to dCount
    end repeat
    repeat with i=1 to (length(truncAbsX) div 3)
      put char 1 to 3 of truncAbsX into item i of y
      delete char 1 to 3 of truncAbsX
    end repeat
    if dCount > 0 then delete char 1 to dCount of first item of y
    if x < 0 then put "-" before y
if abs(x-trunc(x)) is not 0 then add abs(x-trunc(x)) to last item of y
    return y
  end if
end commaFormat


On 13-Jan-06, at 10:37 PM, Marty Knapp wrote:

Message: 21
Date: Fri, 13 Jan 2006 15:40:10 -0800
From: Marty Knapp <[EMAIL PROTECTED]>
Subject: Formatting numbers
To: Revolution User List <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Does somebody have a suggestion for formatting numbers with commas for a
printed report? It wil have columns of data, with numbers ranging from
small to large. The larger ones are hard to read, so I'd like to insert
commas at the appropriate places. I can think of clunky ways to do it,
but thought I'd ask here in case someone had already brewed up something
nice.

Thanks,

Marty Knapp

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to